public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 4/5] linux: Optimize posix_spawn spurious sigaction calls
Date: Mon, 02 Sep 2019 19:47:00 -0000	[thread overview]
Message-ID: <95503672-bc82-c0bc-0a30-5724644b0037@linaro.org> (raw)
In-Reply-To: <87v9uavnzs.fsf@oldenburg2.str.redhat.com>



On 02/09/2019 10:14, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> The problem is in fact false negatives, where posix_spawn will get a mask 
>> *without* the bit set, but with a set signal disposition.
> 
> Hmm.  Right.  Incidentally, the Go routine should be fine with that:
> 
> | // When using cgo, call the C library for sigaction, so that we call into
> | // any sanitizer interceptors. This supports using the memory
> | // sanitizer with Go programs. The memory sanitizer only applies to
> | // C/C++ code; this permits that code to see the Go runtime's existing signal
> | // handlers when registering new signal handlers for the process.
> | 
> | //go:cgo_import_static x_cgo_sigaction
> | //go:linkname x_cgo_sigaction x_cgo_sigaction
> | //go:linkname _cgo_sigaction _cgo_sigaction
> | var x_cgo_sigaction byte
> | var _cgo_sigaction = &x_cgo_sigaction
> 
> libjsig also keeps calling to glibc.
> 
> Is there anything else we should check?

No idea, my take on that is once you start to calling syscall directly
where libbc provide a wrapper you are in your own. We had a similar
discussing with clone usage by some container applications and their
expectation regarding libc internal state afterwards. 

> 
>> In fact I think due the syscall, even relaxed operations would work
>> (since the syscall acts a strong memory barrier).
> 
> Only as a signal fence, not a thread fence.  Some architectures can even
> keep cache inconsistency across fork system calls.
> 
> I find it a bit counter-intuitive that calling sigaction or signal
> directly without the glibc wrappers could lead to data corruption, even
> when done for standard signals such as SIGINT.  But that's what's going
> to happen with this change, unfortunately.

What is counter-intuitive imho is to rely on libc to keep its internal
consistency by bypassing it. This might be even worse if glibc start to
wrapper the signal handler as a way to implement BZ#19702, for instance.

One thing we may do it to make it clean on manual that an application is
*not* expect to call sigaction using syscall().

> 
>>>>> I wonder if we can get kernel support for this in the new clone system
>>>>> call with more flags.  Then we don't have to complicate the sigaction
>>>>> implementation.
>>>>
>>>> Maybe a CLONE_RESET_SIGNALS where the cloned process sets its signal
>>>> disposition to default SIG_IGN/SIG_DFL values may help us here.  However
>>>> afaik clone now is out of space on 'flags' for newer ones (it already
>>>> defines 24 flags plus it reserve 8 bits for signal to be sent at process
>>>> exit) and it would take time to use this feature on glibc.
>>>
>>> Christian Brauner has been working on fixing this.
>>
>> Which strategy he is proposing? Even with proper kernel support, it would
>> take time to enable glibc to use it.
> 
> Lots of flag arguments, with the reset of the arguments located
> indirectly via a pointer argument.
> 
> For a pure optimization, I think it's not too bad to require kernel
> backports of system calls.
> 
> Thanks,
> Florian
> 

  reply	other threads:[~2019-09-02 19:47 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31 18:31 [PATCH v2 1/5] mips: Do not malloc on getdents64 fallback Adhemerval Zanella
2019-07-31 18:31 ` [PATCH v2 5/5] posix: Use posix_spawn for wordexp Adhemerval Zanella
2019-08-28 14:10   ` Adhemerval Zanella
2019-10-07 17:51     ` Adhemerval Zanella
2019-10-07 19:33   ` Florian Weimer
2019-10-07 21:04     ` Carlos O'Donell
2019-10-08  9:58       ` Florian Weimer
2019-10-08 17:41     ` Adhemerval Zanella
2019-10-09  9:11       ` Florian Weimer
2019-10-09 12:18         ` Adhemerval Zanella
2019-07-31 18:31 ` [PATCH v2 2/5] posix: Add posix_spawn_file_actions_closefrom Adhemerval Zanella
2019-08-28 14:09   ` Adhemerval Zanella
2019-08-28 17:22     ` Joseph Myers
2019-08-28 21:03       ` Adhemerval Zanella
2019-07-31 18:31 ` [PATCH v2 3/5] posix: Optimize stack Linux posix_spawn Adhemerval Zanella
2019-08-28 14:09   ` Adhemerval Zanella
2019-10-07 17:50     ` Adhemerval Zanella
2019-07-31 18:31 ` [PATCH 4/5] linux: Optimize posix_spawn spurious sigaction calls Adhemerval Zanella
2019-08-28 14:09   ` Adhemerval Zanella
2019-08-29  8:38   ` Florian Weimer
2019-08-29 11:26     ` Adhemerval Zanella
2019-08-30 10:07       ` Florian Weimer
2019-08-30 13:05         ` Adhemerval Zanella
2019-09-02 13:14           ` Florian Weimer
2019-09-02 19:47             ` Adhemerval Zanella [this message]
2019-10-07 17:51               ` Adhemerval Zanella
2019-10-07 18:25                 ` Christian Brauner
2019-10-07 18:32                   ` Florian Weimer
2019-10-07 21:08                     ` Christian Brauner
2019-10-07 18:35                   ` Adhemerval Zanella
2019-10-07 18:40                     ` Florian Weimer
2019-10-07 19:20                       ` Adhemerval Zanella
2019-10-09  9:37                         ` Florian Weimer
2019-10-09 10:25                           ` Christian Brauner
2019-10-09 12:17                           ` Adhemerval Zanella
2019-10-09 19:16                             ` Florian Weimer
2019-10-07 21:00                     ` Joseph Myers
2019-10-07 18:41                 ` Florian Weimer
2019-08-28 14:09 ` [PATCH v2 1/5] mips: Do not malloc on getdents64 fallback Adhemerval Zanella
2019-08-28 14:35 ` Andreas Schwab
2019-08-28 17:01   ` Adhemerval Zanella
2019-08-28 14:42 ` Florian Weimer
2019-08-28 21:02   ` Adhemerval Zanella
2019-08-28 21:23     ` Florian Weimer
2019-08-29 11:04       ` Adhemerval Zanella
2019-08-30  9:53 ` Florian Weimer
2019-08-30 12:53   ` Adhemerval Zanella
2019-09-02 12:59     ` Florian Weimer
2019-09-02 17:38       ` Adhemerval Zanella
2019-10-07 17:49         ` Adhemerval Zanella
2019-10-07 18:29         ` Florian Weimer
2019-10-08 17:38           ` Adhemerval Zanella
2019-10-08 18:52             ` Florian Weimer
2019-10-08 19:52               ` Adhemerval Zanella
2019-10-08 19:59                 ` Florian Weimer
2019-10-09 13:02                   ` Adhemerval Zanella
2020-11-02 19:51             ` Joseph Myers
2020-11-02 22:10               ` Adhemerval Zanella
2020-11-03 10:27                 ` 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=95503672-bc82-c0bc-0a30-5724644b0037@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.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).