[08/11] misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145)
Commit Message
The syslog open the '/dev/console' for LOG_CONS without O_CLOEXEC,
which might leak in multithread programs that call fork.
Checked on x86_64-linux-gnu.
---
misc/syslog.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Apr 12 2021, Adhemerval Zanella via Libc-alpha wrote:
> The syslog open the '/dev/console' for LOG_CONS without O_CLOEXEC,
> which might leak in multithread programs that call fork.
Ok.
Andreas.
@@ -250,7 +250,8 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap,
*/
int fd;
if (LogStat & LOG_CONS &&
- (fd = __open (_PATH_CONSOLE, O_WRONLY | O_NOCTTY, 0)) >= 0)
+ (fd = __open (_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_CLOEXEC,
+ 0)) >= 0)
{
__dprintf (fd, "%s\r\n", buf + msgoff);
__close (fd);