public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] nptl: Start new threads with all signals blocked [BZ #25098]
Date: Tue, 15 Oct 2019 11:58:00 -0000	[thread overview]
Message-ID: <87bluidxtu.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <20191014133231.sa4zalwbsiybpyvj@wittgenstein> (Christian Brauner's message of "Mon, 14 Oct 2019 15:32:31 +0200")

* Christian Brauner:

> On Mon, Oct 14, 2019 at 02:33:43PM +0200, Florian Weimer wrote:
>> New threads inherit the signal mask from the current thread.  This
>> means that signal handlers can run on the newly created thread
>> immediately after the kernel has created the userspace thread, even
>> before glibc has initialized the TCB.  Consequently, new threads can
>> observe uninitialized ctype data, among other things.
>> 
>> To address this, block all signals before starting the thread, and
>> pass the original signal mask to the start routine wrapper.  On the
>> new thread, first perform all thread initialization, and then unblock
>> signals.
>> 
>> The cost of doing this is two rt_sigprocmask system calls on the old
>> thread, and one rt_sigprocmask system call on the new thread.  (If
>> there was a way to clone a new thread with a signals disabled, this
>
> He, do I see a growing wishlist? :)

Maybe.  I think the handler reset is more important because as
Adhemerval explained, it saves many more system calls.

Thanks,
Florian

  reply	other threads:[~2019-10-15 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:33 Florian Weimer
2019-10-14 13:32 ` Christian Brauner
2019-10-15 11:58   ` Florian Weimer [this message]
2019-10-15 12:03     ` Christian Brauner
2019-10-17 18:34 ` Adhemerval Zanella
2019-10-17 21:49   ` Florian Weimer
2019-10-18 12:20     ` Adhemerval Zanella
2019-11-29 11:08 Florian Weimer

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=87bluidxtu.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=libc-alpha@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).