Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 25 Jan 2021 20:37:58 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: insufficient checking in
 posix_spawn_file_actions_add{open,dup2}

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.