mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] MT fork and key_lock in pthread_key_create.c
Date: Thu, 6 Oct 2022 14:21:51 -0400	[thread overview]
Message-ID: <20221006182151.GV29905@brightrain.aerifal.cx> (raw)
In-Reply-To: <033092a85a52d9f8e8d73a235e2381ae@ispras.ru>

On Thu, Oct 06, 2022 at 09:37:50AM +0300, Alexey Izbyshev wrote:
> Hi,
> 
> I noticed that fork() doesn't take key_lock that is used to protect
> the global table of thread-specific keys. I couldn't find mentions
> of this lock in the MT fork discussion in the mailing list archive.
> Was this lock overlooked?

I think what happened was that we made the main list of locks to
review and take care of via grep for LOCK, and then manually added
known instances of locks using other locking primitives. This one must
have been missed.

Having special-case lock types like this is kinda a pain, but as long
as there aren't too many I guess it's not a big deal.

> Also, I looked at how __aio_atfork() handles a similar case with
> maplock, and it seems wrong. It takes the read lock and then simply
> unlocks it both in the parent and in the child. But if there were
> other holders of the read lock at the time of fork(), the lock won't
> end up in the unlocked state in the child. It should probably be
> completely nulled-out in the child instead.

Conceptually, perhaps it should be taking the write-lock instead?
But null-out is probably okay too, and less costly.

Rich

  parent reply	other threads:[~2022-10-06 18:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06  6:37 Alexey Izbyshev
2022-10-06  7:02 ` [musl] " Alexey Izbyshev
2022-10-06 19:20   ` Rich Felker
2022-10-06 19:50     ` Rich Felker
2022-10-07  1:26       ` Rich Felker
2022-10-07 10:53         ` Alexey Izbyshev
2022-10-07 21:18           ` Rich Felker
2022-10-08 16:07             ` Alexey Izbyshev
2022-10-07  8:18       ` Alexey Izbyshev
2022-10-06 20:04     ` Jeffrey Walton
2022-10-06 20:09       ` Rich Felker
2022-10-06 18:21 ` Rich Felker [this message]
2022-10-08  1:36   ` [musl] " Rich Felker
2022-10-08 17:03     ` Alexey Izbyshev
2022-10-11 17:50       ` Rich Felker

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=20221006182151.GV29905@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).