From: anteater <65555601+nt8r@users.noreply.github.com> Date: Mon, 29 May 2023 20:59:11 +0000 (+0000) Subject: dmesg: make kmsg read() buffer big enough for kernel X-Git-Tag: v2.39.1~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9429cc72b5923ca3380235283b969365723643e5;p=thirdparty%2Futil-linux.git dmesg: make kmsg read() buffer big enough for kernel otherwise, if the kernel log has an item longer than 1024B, our read() gives EINVAL and we stop reading kmsg --- diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 45075e50bd..717cc588b2 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -179,7 +179,13 @@ struct dmesg_control { int kmsg; /* /dev/kmsg file descriptor */ ssize_t kmsg_first_read;/* initial read() return code */ - char kmsg_buf[BUFSIZ];/* buffer to read kmsg data */ + /* + * the kernel will give EINVAL if we do read() on /proc/kmsg with + * length insufficient for the next message. messages may be up to + * PRINTK_MESSAGE_MAX, which is defined as 2048, so we must be + * able to buffer at least that much in one call + */ + char kmsg_buf[2048]; /* buffer to read kmsg data */ usec_t since; /* filter records by time */ usec_t until; /* filter records by time */