]> Git Repo - linux.git/commitdiff
printk: fix string termination for record_print_text()
authorJohn Ogness <[email protected]>
Sun, 24 Jan 2021 20:27:28 +0000 (21:33 +0106)
committerPetr Mladek <[email protected]>
Mon, 25 Jan 2021 09:37:08 +0000 (10:37 +0100)
Commit f0e386ee0c0b ("printk: fix buffer overflow potential for
print_text()") added string termination in record_print_text().
However it used the wrong base pointer for adding the terminator.
This led to a 0-byte being written somewhere beyond the buffer.

Use the correct base pointer when adding the terminator.

Fixes: f0e386ee0c0b ("printk: fix buffer overflow potential for print_text()")
Reported-by: Sven Schnelle <[email protected]>
Signed-off-by: John Ogness <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
kernel/printk/printk.c

index 17fa6dc77053b370a55125eaa8683a84e589b8f6..c55cd18206895c53dd0974206c80f9298b3845e4 100644 (file)
@@ -1399,7 +1399,7 @@ static size_t record_print_text(struct printk_record *r, bool syslog,
         * not counted in the return value.
         */
        if (buf_size > 0)
-               text[len] = 0;
+               r->text_buf[len] = 0;
 
        return len;
 }
This page took 0.045423 seconds and 4 git commands to generate.