From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id CBC2D1F462 for ; Thu, 23 May 2019 23:47:08 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:references:from:subject:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=c4cbqDSxtMDJsHDb 9kmpA9cCD+DrB9QbFIXpR2ffH3PpVtDovfqVdViairz4yfNz9iyvqi6Urd0nn1mh TMoRqbKMdVQYs65ZGOcHDZeqPEAQIRSvc7c5Hm1HQJUFRDcSzayFC1A95H2vJqzc VsUHXdxkpFLdE6B7babvN2XWVkc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:references:from:subject:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=jl8QPLfa0/qeR+d9Km25hy yYYWQ=; b=UaDhImNrcLbSsHA2qu1cGEGB1UIEJvUE5z/Q5UffdtMcKldwwgyTXA d+fXU0pRQrtCUvWTslpuQvUctTRA8T8JPAc112AN9d/BdUVfG8vvcRIazgB1kN9D 3IlKqyl3V4+EvhHHGhu1Id+IzQ3+SHUsqSXiisYNLTtq8yGkWywZw= Received: (qmail 98249 invoked by alias); 23 May 2019 23:47:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 98241 invoked by uid 89); 23 May 2019 23:47:06 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-vs1-f54.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:cc:references:from:openpgp:autocrypt:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YN+KSlu6+eP9edgtfYh3L5N7RPwTQX5Xmx2bpdhzJkU=; b=tHvrJcQxo2NvUqcp1irdiMjuSzJwdiNPlehCfilOjMGoWviYlIEhQuRuua3hB+aSez cf4NpgCQjIW/82sdNGrnMgY0/7Oml+9jI3h5b3/sQLPI8/C/wSF69XJMoFtJRJXkiMey 0QV6BnHool36lq2kF5dvAyPQYCb0rwF+Rf5HrPQYkWq65gw2QNm1rSzJKohriKlMkKmh juUKBifekaiHjc/jHHfVJ0ZdQNgORbonQ6rtbt4d0QKyrwLnkgTLIXHkl1krgrB7SvXC lSzj7YyRkp8z6jCdjvZukRe9Tgs/1cBtOvt3pf8MD9ryFHOuh1dZjfUeIDFs5cMfF9Jm 3o7A== To: Florian Weimer Cc: Carlos O'Donell , libc-alpha@sourceware.org References: <20190523133048.14922-1-adhemerval.zanella@linaro.org> <77021a69-c1a9-b41a-4396-5201915e3fa3@linaro.org> <87blztulg7.fsf@oldenburg2.str.redhat.com> <87lfyxt0fk.fsf@mid.deneb.enyo.de> From: Adhemerval Zanella Openpgp: preference=signencrypt Subject: Re: [PATCH] nptl: Fix deadlock on atfork handler which calls dlclose (BZ#24595) Message-ID: <9b7c942b-ffba-4032-0d85-42a3b401d12f@linaro.org> Date: Thu, 23 May 2019 20:46:59 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <87lfyxt0fk.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 23/05/2019 16:50, Florian Weimer wrote: > * Adhemerval Zanella: > >> The solution sounds correct, but I don't have a strong opinion if this >> is really an improvement over a recursive lock plus a linked list. It >> potentially adds 'free' calls in fork for multithread mode if list needs >> to be deallocated. Also, since the locks is internal to register-atfork.c >> we might have a better control to make the exported interfaces not >> deadlock. > > Recursive locks do not prevent deadlocks if the callback launches > threads. I'm not sure if this can be considered a stretch. If > there's dlclose involved, their might also be dlopen, and threads > launched from an ELF constructor and so on. That's why I said the core issue is atfork handlers are really underspecified, and maybe it would be better if we document more thoughtfully what we really aim to support by atfork handlers. > > Furthermore, I'm not sure if the implementation of __unregister_atfork > is correct. I think you have a potential use-after-free issue if the > callback deregisters a fork handler. > The possible way I can think of is if an atfork handler from a module try to dlclose itself and I am not sure how valid it is. Anyhow, I will implement your suggestion and check the resulting code. I really would like to avoid introduce a free call to fork again and make this rather complex atfork handler simpler.