From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23077 invoked from network); 20 Jul 2023 14:22:22 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 20 Jul 2023 14:22:22 -0000 Received: (qmail 16340 invoked by uid 550); 20 Jul 2023 14:22:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 16302 invoked from network); 20 Jul 2023 14:22:19 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 95B12407675E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1689862927; bh=U5i7EV8b6cOb7JdDV/V2BNUDxH/5ndEl1Bu5ENOi+BI=; h=Date:From:To:Subject:In-Reply-To:References:From; b=MWk8UqM4Ym08UxyU2kFoby9z+AuASfjX8RbiiyE1IwsfBM+KkJlSjLUoD7i8/qNh6 K7wOSjpDinty3Rho3Og0TKomxd9/Bapn6UZrjXfPCE2nf4t5ikJyt8C2ZoKM6754Fg fVzg5HtYVVYOYM4AvC0e1QbpUb0bbAM36rW1unlY= MIME-Version: 1.0 Date: Thu, 20 Jul 2023 17:22:07 +0300 From: Alexey Izbyshev To: musl@lists.openwall.com In-Reply-To: <953a6adcee154977b4695bb9e485225c@huawei.com> References: <953a6adcee154977b4695bb9e485225c@huawei.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: izbyshev@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [musl] [PATCH] set tid address in fork On 2023-07-20 16:53, changdiankang wrote: > In pthrad_exit the exiting thread will hold the thread list lock, > and will unlock it in kernel by clear the tid address > &__thread_list_lock. > > A thread created by pthrad_create is created with clone syscall with > CLONE_CHILD_CLEARTID flag and &__thread_list_lock as child_tid > parameter. When the thread exits, the thread list lock can be woke up > (see man clone CLONE_CHILD_CLEARTID). > > But in fork, the main thread is created with fork syscall or with > clone syscall without CLONE_CHILD_CLEARTID flag. The > &__thread_list_lock > is not be set to tid address. So when the main thread exits, the thread > list lock can't be woke up by kernel. This may lead some problems when > other child threads try to hold this lock. For example, a child thread > blocks at waiting thread list lock when joining the main thread. > > To fix this issue, we should set &__thread_list_lock to the main thread > tid > address in fork. This bug has already been discovered, see https://www.openwall.com/lists/musl/2023/06/01/9. Alexey