From: Adhemerval Zanella Date: Sun, 11 Apr 2021 02:29:40 +0000 (-0300) Subject: misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145) X-Git-Tag: glibc-2.34~653 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=7f3ab33f20f19ad5b8fdd40bd77d35a0da355347;p=glibc.git misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145) 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. --- diff --git a/misc/syslog.c b/misc/syslog.c index 18330a373b..e228860d22 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -284,7 +284,8 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap, * syslogd failure. */ 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); (void)__close(fd);