[PATCH v2] Ensure standard file descriptors are open on start
Zack Weinberg
zackw@panix.com
Wed Aug 19 17:46:23 GMT 2020
On Wed, Aug 19, 2020 at 12:28 PM Joseph Myers <joseph@codesourcery.com> wrote:
> On Wed, 19 Aug 2020, Arsen Arsenović via Libc-alpha wrote:
>
> > ISO C requires that standard input, output and error are always open on
> > program startup.
>
> ISO C doesn't talk about file descriptors at all. The objects stdin,
> stdout and stderr need to be initialized, but it's fine for all I/O on
> them to fail.
>
> > + /* Ensure the standard streams are opened, as required by POSIX and C. For
> > + dynamic programs this is already handled in the dynamic loader. */
>
> Please give specific references, not just "as required by POSIX and C".
> What exactly do you think requires these descriptors to be open?
Are you raising a hard objection to this change, Joseph? I think it
makes sense just on QoI grounds. Specifically, the reason we already
do this for set-ID programs (it could be very bad if the program
accidentally writes to a file that it didn't expect to be assigned fd
1 or 2) seems to apply nearly as well to ordinary programs (it's not a
_security_ issue but it could still cause data loss).
zw
More information about the Libc-alpha
mailing list