From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19960 invoked from network); 25 Jan 2021 19:38:12 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 25 Jan 2021 19:38:12 -0000 Received: (qmail 26483 invoked by uid 550); 25 Jan 2021 19:38:11 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26465 invoked from network); 25 Jan 2021 19:38:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611603479; bh=UDvKycUXExaKAA0dzgeMG2ttnJdopkz4hlFrDHMESgc=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=hcy0/j3u8TDEOna0OUH/nyC5inbPYRLZalNoHQj+FKy5dUjdvwl3DGjnauoDVgJwm wLPsk/zqHGj2a+SWOvw6Py28L1eBYOKQB4IcdOO86Z0c2xO1iFMovLHhuxmesBw8OG xL1dkWPCC6b9s6MNyI7fScc8yTH/u67WCMMOcQ+E= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Date: Mon, 25 Jan 2021 20:37:58 +0100 From: Markus Wichmann To: musl@lists.openwall.com Message-ID: <20210125193758.GC2006@voyager> References: <3521697.b4TYcCAa2N@omega> <20210125144236.GV23432@brightrain.aerifal.cx> <2658009.jRRjQAZNrc@omega> <20210125161512.GW23432@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210125161512.GW23432@brightrain.aerifal.cx> User-Agent: Mutt/1.9.4 (2018-02-28) X-Provags-ID: V03:K1:rphpze55A1chQH3R+NG0kEvjGeye3B7o3bDb8OoswwPyruFkOKA f9FPZcvvy/vyH4lqFvzVjQ84+/GsEIjtTDPy0OuoPrcV9WkBWHuO28Sfhppv7n0+O2h1nPm aJj9lIHYj9GhU3gS/9CkAd6JKcZDXCzDgyqBonmdNa0a2kba07T1fkLZNiZOz11juXm3ids eugQjF4d7jF0bAiAN8eEg== X-UI-Out-Filterresults: notjunk:1;V03:K0:5tgUpzhZO7o=:klA2KnQp1C8QLW60IGSk+d UNhpNzy+/O94sgnGjAUWKsVZxSufYaSNN6D0qddMWZKkOC7nKuGVm8sZFvre7emqsfGb+Rti5 jMV1PxNloZFfhvzkTS3FATkW3FVI1+rTGTf74e9Z3MY45esEbOM3jFE4dlmzZmImuI7mQ89K3 UGG6v9uvtx0vYGjTlfMCmfBGoICOJtPdJos+dXdSS4rmKGed94L0SQljOoc9n8v7mtAXb6TlK 9MhdkMckOcDSytnF4c7HcIWcNd6yUrTRId/m59ROXq7dpapGlngzBufxrQ9LwK0mLDq1xdx27 nGiJDUo0KzYUSyiYta7lUZO8HaXpM282F4p6Df5c3q+inzPO4HTvdCQQrSpHc/IFV/mQLtYhg bleRB6kTee8N+oorMlqOzHlpJdgrzkpRGA7VbFS+1k4eK2zbPTVT8Duw9siaRl3w9Dm/iYbS3 eXAD3hL/E9nAkGYZFDQzv7oENHzUC2lgyvOasfEBoDc6+gyZzLNVJ6Fn4W5MgmtZZbvSUJOvL ILD/SpK13k8RdY5W3HZCVIu7XKPKK1rUmWZ8dtJpWsp7/7OJMy4oaOy5oI9/5nvG4cPeelKmm Tb9v/RC3VzBFG3JlvS6lYmAPUU8wsKJ0JFrFHuP/mzfL3uSX/dZuq3d+UdL4xY99ecO73Ea6Y 8PcZOXbcz3mCt4cL8qOKq+wzRc9CFspyHKCuBrNup2i7YoQGhfTbxhCAOVp2CFxE6x0pHNud5 2UgMClVgV7aW/zWMEYNT7IE5GZPLRz+OGwg5SLHeRSyvddM0OIFLLd/evdk8MukOPK1+2BAoQ mDHUdLjt8oh9U2W4NBwDjMQX5h5BPTvCk59S0C2BtZ0Zk+F5r2/zoS7iY7Xy5QVQBD/E0hZPt FB+y9nyPCta2hUrz7dug== Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] 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