unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Christian Brauner <christian.brauner@ubuntu.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: libc-alpha <libc-alpha@sourceware.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [RFC PATCH glibc 3/8] nptl: Start new threads with all signals blocked [BZ #25098]
Date: Mon, 23 Mar 2020 18:05:03 +0100	[thread overview]
Message-ID: <20200323170503.dkaad3zmwe5owc4p@wittgenstein> (raw)
In-Reply-To: <1742466479.7642.1584982932053.JavaMail.zimbra@efficios.com>

On Mon, Mar 23, 2020 at 01:02:12PM -0400, Mathieu Desnoyers via Libc-alpha wrote:
> ----- On Mar 23, 2020, at 11:31 AM, Christian Brauner christian.brauner@ubuntu.com wrote:
> 
> > On Mon, Mar 23, 2020 at 09:16:02AM -0400, Mathieu Desnoyers via Libc-alpha
> > wrote:
> >> From: Florian Weimer <fweimer@redhat.com>
> >> 
> >> 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
> > 
> > This could be a new clone3() flag. If someone wants to send a patch I'd
> > take it.
> 
> I agree that it would be a nice improvement to alleviate the overhead of
> tweaking the signal masks on thread creation. I suspect the code proposed in
> this patch is still needed, because glibc would have to support the currently
> existing kernels. The improvement you envision involves adding this new flag
> into the Linux kernel clone3 system call and then wiring up glibc support.
> 
> I don't expect this should delay rseq integration into glibc ?

Oh no, I wasn't trying to say that rseq() in glibc should be blocked on
this, not at all. I was just saying we should probably do this since
it's a valuable improvement.

Christian

  reply	other threads:[~2020-03-23 17:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 13:15 [RFC PATCH glibc 0/8] Restartable Sequences enablement Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 1/8] Introduce <elf_machine_sym_no_match.h> Mathieu Desnoyers via Libc-alpha
2020-03-23 14:51   ` H.J. Lu via Libc-alpha
2020-03-23 17:04     ` Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 2/8] Implement __libc_early_init Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 3/8] nptl: Start new threads with all signals blocked [BZ #25098] Mathieu Desnoyers via Libc-alpha
2020-03-23 15:31   ` Christian Brauner
2020-03-23 17:02     ` Mathieu Desnoyers via Libc-alpha
2020-03-23 17:05       ` Christian Brauner [this message]
2020-04-22 16:38         ` Carlos O'Donell via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 4/8] glibc: Perform rseq(2) registration at C startup and thread creation (v16) Mathieu Desnoyers via Libc-alpha
2020-03-23 22:01   ` Joseph Myers
2020-03-24 13:08     ` Mathieu Desnoyers via Libc-alpha
2020-03-24 18:58       ` Joseph Myers
2020-03-24 19:44         ` Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 5/8] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux (v7) Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 6/8] support record failure: allow use from constructor Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 7/8] support: implement xpthread key create/delete (v4) Mathieu Desnoyers via Libc-alpha
2020-03-23 13:16 ` [RFC PATCH glibc 8/8] rseq registration tests (v9) Mathieu Desnoyers via Libc-alpha
  -- strict thread matches above, loose matches on Subject: below --
2020-03-19 14:41 [RFC PATCH glibc 0/8] Restartable Sequences enablement Mathieu Desnoyers via Libc-alpha
2020-03-19 14:41 ` [RFC PATCH glibc 3/8] nptl: Start new threads with all signals blocked [BZ #25098] Mathieu Desnoyers via Libc-alpha
2020-01-08 14:58 [RFC PATCH glibc 0/8] Restartable Sequences enablement Mathieu Desnoyers
2020-01-08 14:58 ` [RFC PATCH glibc 3/8] nptl: Start new threads with all signals blocked [BZ #25098] Mathieu Desnoyers

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200323170503.dkaad3zmwe5owc4p@wittgenstein \
    --to=christian.brauner@ubuntu.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=mathieu.desnoyers@efficios.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.
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).