]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Sun, 11 Apr 2021 02:29:40 +0000 (23:29 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 15 Apr 2021 14:32:40 +0000 (11:32 -0300)
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

index 18330a373bf39fc89452442cc23c06762daad9f3..e228860d22fe080aaa09f08b1ed027bbdc5654ec 100644 (file)
@@ -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);