From 6798fe76d5fd952ac2614d00cd950cb86f76a24b Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 14 Mar 2022 06:59:51 +0100 Subject: [PATCH] Document reason for stat() in opensys() Signed-off-by: Joachim Wiberg --- src/syslogd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/syslogd.c b/src/syslogd.c index e55e011..2426fa1 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -668,6 +668,13 @@ static int opensys(const char *file) struct stat st; int fd; + /* + * In some (container) use-cases /dev/kmsg might not be a proper + * FIFO, which may lead to CPU overload and possible loss of + * function. This check, along with the in_container() function + * is an attempt to remedy such scenarios. It's merely a sanity + * check, so ignore any TOCTOU warnings this might cause. + */ if (stat(file, &st) || !S_ISCHR(st.st_mode)) return 1;