From: David Laight <David.Laight@ACULAB.COM>
To: 'Szabolcs Nagy' <nsz@port70.net>,
Christian Brauner <christian.brauner@ubuntu.com>
Cc: "torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Kyle Evans <self@kyle-evans.net>,
Victor Stinner <victor.stinner@gmail.com>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
"fweimer@redhat.com" <fweimer@redhat.com>,
"jannh@google.com" <jannh@google.com>,
"oleg@redhat.com" <oleg@redhat.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"shuah@kernel.org" <shuah@kernel.org>,
"dhowells@redhat.com" <dhowells@redhat.com>,
"ldv@altlinux.org" <ldv@altlinux.org>
Subject: RE: [PATCH v5 1/3] open: add close_range()
Date: Sun, 7 Jun 2020 13:22:48 +0000 [thread overview]
Message-ID: <46cd4282193641bf801fb150d482c624@AcuMS.aculab.com> (raw)
In-Reply-To: <20200605145549.GC673948@port70.net>
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)
next prev parent reply other threads:[~2020-06-07 13:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 20:42 [PATCH v5 0/3] close_range() Christian Brauner
2020-06-02 20:42 ` [PATCH v5 1/3] open: add close_range() Christian Brauner
2020-06-02 23:30 ` Florian Weimer
2020-06-02 23:37 ` Christian Brauner
2020-06-03 10:24 ` Michael Kerrisk (man-pages)
2020-09-17 7:52 ` Michael Kerrisk (man-pages)
2020-06-05 14:55 ` Szabolcs Nagy
2020-06-06 2:54 ` Kyle Evans
2020-06-06 3:11 ` Kyle Evans
2020-06-06 11:55 ` Szabolcs Nagy
2020-06-06 14:43 ` Kyle Evans
2020-06-07 13:22 ` David Laight [this message]
2020-06-02 20:42 ` [PATCH v5 2/3] arch: wire-up close_range() Christian Brauner
2020-06-02 20:42 ` [PATCH v5 3/3] tests: add close_range() tests Christian Brauner
2020-06-02 21:03 ` [PATCH v5 0/3] close_range() Linus Torvalds
2020-06-02 23:33 ` Christian Brauner
2020-06-03 0:08 ` Linus Torvalds
2020-06-03 23:24 ` Christian Brauner
2020-06-04 0:13 ` Linus Torvalds
2020-06-04 1:15 ` Christian Brauner
2020-06-07 12:31 ` David Laight
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=46cd4282193641bf801fb150d482c624@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=arnd@arndb.de \
--cc=christian.brauner@ubuntu.com \
--cc=dhowells@redhat.com \
--cc=fweimer@redhat.com \
--cc=jannh@google.com \
--cc=ldv@altlinux.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nsz@port70.net \
--cc=oleg@redhat.com \
--cc=self@kyle-evans.net \
--cc=shuah@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=victor.stinner@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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.
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).