[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <46cd4282193641bf801fb150d482c624@AcuMS.aculab.com>
Date: Sun, 7 Jun 2020 13:22:48 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Szabolcs Nagy' <nsz@...t70.net>,
Christian Brauner <christian.brauner@...ntu.com>
CC: "torvalds@...ux-foundation.org" <torvalds@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Kyle Evans <self@...e-evans.net>,
Victor Stinner <victor.stinner@...il.com>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
"fweimer@...hat.com" <fweimer@...hat.com>,
"jannh@...gle.com" <jannh@...gle.com>,
"oleg@...hat.com" <oleg@...hat.com>,
"arnd@...db.de" <arnd@...db.de>,
"shuah@...nel.org" <shuah@...nel.org>,
"dhowells@...hat.com" <dhowells@...hat.com>,
"ldv@...linux.org" <ldv@...linux.org>
Subject: RE: [PATCH v5 1/3] open: add close_range()
From: Szabolcs Nagy
> Sent: 05 June 2020 15:56
...
> currently there is no libc interface contract in place that
> says which calls may use libc internal fds e.g. i've seen
>
> openlog(...) // opens libc internal syslog fd
> ...
> fork()
> closefrom(...) // close syslog fd
> open(...) // something that reuses the closed fd
> syslog(...) // unsafe: uses the wrong fd
> execve(...)
>
> syslog uses a libc internal fd that the user trampled on and
> this can go bad in many ways depending on what libc apis are
> used between closefrom (or equivalent) and exec.
It is, of course, traditional that daemons only call
close(0); close(1); close(2);
Took us ages to discover that a misspelt fprintf()
was adding data to the stdout buffer and eventually
flushing 10k of ascii text into an inter-process pipe
that had a 32bit field for 'message extension length'.
FWIW isn't syslog() going to go badly wrong after fork()
anyway?
Unless libc's fork() calls closelog().
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists