[PATCH v2] Ensure standard file descriptors are open on start
Arsen Arsenović
arsen@aarsen.me
Wed Aug 19 19:40:25 GMT 2020
> Please give specific references, not just "as required by POSIX and C".
> What exactly do you think requires these descriptors to be open?
The sections that lead me to believe this were:
http://www.iso-9899.info/n1570.html#7.21.3p7
https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_05
What would be the best way to reference these in source code? I can wait for
some more potential feedback to aggregate, and for a consensus to be reached,
before updating the patch with that, to reduce patch spam.
POSIX also, in other pages, occasionally mentions the danger of a file being
unexpectedly open as one of three special file descriptors, which I presume is
the reason for the hardening glibc was already doing for SUID binaries.
> "If a standard utility or a conforming application is executed with file
> descriptor 0 not open for reading or with file descriptor 1 or 2 not open for
> writing, the environment in which the utility or application is executed shall
> be deemed non-conforming, and consequently the utility or application might
> not behave as described in this standard."
This specific part of the quote would seem to imply that standard input, output
and error must be opened for reading and writing respectively?
Or do you think this only applies if the implementation decides to handle
opening the file descriptors?
--
Arsen Arsenović
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20200819/162ebc72/attachment.sig>
More information about the Libc-alpha
mailing list