mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] insufficient checking in posix_spawn_file_actions_add{open,dup2}
Date: Mon, 25 Jan 2021 20:37:58 +0100	[thread overview]
Message-ID: <20210125193758.GC2006@voyager> (raw)
In-Reply-To: <20210125161512.GW23432@brightrain.aerifal.cx>

On Mon, Jan 25, 2021 at 11:15:12AM -0500, Rich Felker wrote:
> In the case of getpid, because glibc does (or at least did? not sure
> if they still do) cache it themselves in the TCB, adding it to vdso
> offered no additional concrete benefit.
>
> Rich

They no longer do that. The manpage says they did, but stopped because
people kept running the fork, vfork, and clone system calls directly.
What eventually killed the caching was an irreconcilable race condition
in the clone() wrapper function: If the child received a signal right
after being created but before the getpid() cache was invalidated,
getpid() (which is specified as being async-signal-safe) would return
invalid values. Now, this is fixable by blocking signals during that
time, but that would be a lot of work for little benefit.

Adding a getpid vDSO call would require adding the code itself, adding
the PID to the vvar page (isn't that shared among all processes?), and
adding support for finding the vDSO function into the libcs. All of that
for rather dubious performance benefits (or can you name a program that
was not fast enough because getpid() ran too slowly?)

Ciao,
Markus

  parent reply	other threads:[~2021-01-25 19:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25  8:31 Bruno Haible
2021-01-25  8:40 ` [musl] insufficient checking in posix_spawn_file_actions_addclose Bruno Haible
2021-01-25 14:42 ` [musl] insufficient checking in posix_spawn_file_actions_add{open,dup2} Rich Felker
2021-01-25 16:07   ` Bruno Haible
2021-01-25 16:15     ` Rich Felker
2021-01-25 17:58       ` Bruno Haible
2021-01-25 19:33       ` Alexey Izbyshev
2021-01-25 19:37       ` Markus Wichmann [this message]
2021-01-25 19:48         ` 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=20210125193758.GC2006@voyager \
    --to=nullplan@gmx.net \
    --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).