lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sun, 3 May 2020 13:52:45 +0000 From: David Laight <David.Laight@...LAB.COM> To: "'Karstens, Nate'" <Nate.Karstens@...min.com>, Eric Dumazet <eric.dumazet@...il.com>, Alexander Viro <viro@...iv.linux.org.uk>, "Jeff Layton" <jlayton@...nel.org>, "J. Bruce Fields" <bfields@...ldses.org>, "Arnd Bergmann" <arnd@...db.de>, Richard Henderson <rth@...ddle.net>, "Ivan Kokshaysky" <ink@...assic.park.msu.ru>, Matt Turner <mattst88@...il.com>, "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>, Helge Deller <deller@....de>, "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>, "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>, "linux-alpha@...r.kernel.org" <linux-alpha@...r.kernel.org>, "linux-parisc@...r.kernel.org" <linux-parisc@...r.kernel.org>, "sparclinux@...r.kernel.org" <sparclinux@...r.kernel.org>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org> CC: Changli Gao <xiaosuo@...il.com> Subject: RE: [PATCH 1/4] fs: Implement close-on-fork From: Karstens, Nate > Sent: 01 May 2020 15:45 > Thanks for the suggestion. I looked into it and noticed that do_close_on_exec() appears to have some > optimizations as well: > > > set = fdt->close_on_exec[i]; > > if (!set) > > continue; > > If we interleave the close-on-exec and close-on-fork flags then this optimization will have to be > removed. Do you have a sense of which optimization provides the most benefit? Thinks.... A moderate proportion of exec() will have at least one fd with 'close on exec' set. Very few fork() will have any fd with 'close on fork' set. The 'close on fork' table shouldn't be copied to the forked process. The 'close on exec' table is deleted by exec(). So... On fork() take a copy and clear the 'close_on_fork' bitmap. For every bit set lookup the fd and close if the live bit is set. Similarly exec() clears and acts on the 'close on exec' map. You should be able to use the same 'close the fds in this bitmap' function for both cases. So I think you need two bitmaps. But the code needs to differentiate between requests to set bits (which need to allocate/extend the bitmap) and ones to clear/read bits (which do not). You might even consider putting the 'live' flag into the fd structure and using the bitmap value as a 'hint' - which might be hashed. After all, it is likely that the 'close on exec' processing will be faster overall if it just loops through the open fd and checks each in turn! I doubt many processes actually exec with more than an handful of open files. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Powered by blists - more mailing lists