diff options
Diffstat (limited to 'debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch')
-rw-r--r-- | debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch b/debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch new file mode 100644 index 000000000..6b64b9ca9 --- /dev/null +++ b/debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch @@ -0,0 +1,44 @@ +From: John Ogness <john.ogness@linutronix.de> +Date: Mon, 7 Oct 2019 16:20:39 +0200 +Subject: [PATCH] printk: handle iterating while buffer changing +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz + +The syslog and kmsg_dump readers are provided buffers to fill. +Both try to maximize the provided buffer usage by calculating the +maximum number of messages that can fit. However, if after the +calculation, messages are dropped and new messages added, the +calculation will no longer match. + +For syslog, add a check to make sure the provided buffer is not +overfilled. + +For kmsg_dump, start over by recalculating the messages +available. + +Signed-off-by: John Ogness <john.ogness@linutronix.de> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/printk/printk.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/kernel/printk/printk.c ++++ b/kernel/printk/printk.c +@@ -1446,6 +1446,9 @@ static int syslog_print_all(char __user + break; + } + ++ if (len + textlen > size) ++ break; ++ + if (copy_to_user(buf + len, text, textlen)) + len = -EFAULT; + else +@@ -3085,7 +3088,7 @@ bool kmsg_dump_get_buffer(struct kmsg_du + ret = prb_iter_next(&iter, msgbuf, PRINTK_RECORD_MAX, &seq); + if (ret == 0) { + break; +- } else if (ret < 0) { ++ } else if (ret < 0 || seq >= end_seq) { + prb_iter_init(&iter, &printk_rb, &seq); + goto retry; + } |