From: Rich Felker <dalias@libc.org>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] set tid address in fork
Date: Thu, 20 Jul 2023 13:30:43 -0400 [thread overview]
Message-ID: <20230720173042.GP4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <d0e8ce1ad8d574ad69638fa913f74593@ispras.ru>
On Thu, Jul 20, 2023 at 05:22:07PM +0300, Alexey Izbyshev wrote:
> 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.
Yes, and the fix is in an unpushed commit. Sorry! I'll review queue
and push in a bit.
Rich
prev parent reply other threads:[~2023-07-20 17:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 13:53 changdiankang
2023-07-20 14:22 ` Alexey Izbyshev
2023-07-20 17:30 ` Rich Felker [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230720173042.GP4163@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=izbyshev@ispras.ru \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).