unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers via Libc-alpha <libc-alpha@sourceware.org>
To: Christian Brauner <christian.brauner@ubuntu.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 13:02:12 -0400 (EDT)	[thread overview]
Message-ID: <1742466479.7642.1584982932053.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20200323153156.hpdjqghjscivggjf@wittgenstein>

----- 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 ?

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2020-03-23 17:02 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 [this message]
2020-03-23 17:05       ` Christian Brauner
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=1742466479.7642.1584982932053.JavaMail.zimbra@efficios.com \
    --to=libc-alpha@sourceware.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=joseph@codesourcery.com \
    --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).