printk: fix discarding message when recursion_bug
PATCH 1/1 printk: fix discarding message when recursion_bug
From: Hiroshi Shimamoto <[email protected]>
Impact: fix
When recursion_bug is true, kernel discards original message because printk_buf contains recursion_bug_msg with NULL terminator. The sizeof(recursion_bug_msg) makes this, use strlen() to get correct length without NULL terminator.
--- kernel/printk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/printk.c +1 -1
@@ -662,7 +662,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)if (recursion_bug) { recursion_bug =0 ;strcpy (printk_buf, recursion_bug_msg); - printed_len =sizeof (recursion_bug_msg); + printed_len =strlen (recursion_bug_msg); }/* Emit the output into the temporary buffer */ printed_len += vscnprintf(printk_buf + printed_len,
Signature · 1 line
1.6.0.4
Quoted 8 lines · Hiroshi Shimamoto
From: Hiroshi Shimamoto <[email protected]>
Impact: fix
When
recursion_bugis true, kernel discards original message becauseprintk_bufcontainsrecursion_bug_msgwith NULL terminator. Thesizeof(recursion_bug_msg)makes this, usestrlen()to get correct length without NULL terminator.
Quoted 5 lines
Reported-by Toshikazu Nakayama <[email protected]>Signed-off-by Hiroshi Shimamoto <[email protected]>--- kernel/printk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Good one - applied to tip/core/printk, thanks!
Btw., i'm curious: in what situation was such recursion observed, and how did the kernel behave? You saw a truncated recursion message in dmesg - or was it worse?
Ingo
Quoted 16 lines · Ingo Molnar
Quoted 8 lines · Hiroshi Shimamoto
From: Hiroshi Shimamoto <[email protected]>
Impact: fix
When
recursion_bugis true, kernel discards original message becauseprintk_bufcontainsrecursion_bug_msgwith NULL terminator. Thesizeof(recursion_bug_msg)makes this, usestrlen()to get correct length without NULL terminator.Quoted 5 lines
Reported-by Toshikazu Nakayama <[email protected]>Signed-off-by Hiroshi Shimamoto <[email protected]>--- kernel/printk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 5 lines
Good one - applied to tip/core/printk, thanks!
Btw., i'm curious: in what situation was such recursion observed, and how did the kernel behave? You saw a truncated recursion message in dmesg - or was it worse?
I'm not sure about the real situation. I've heard this issue was found in printing messages in NMI handler, maybe with artificial kernel stuck.
Thanks,
Hiroshi
Quoted 17 lines · Hiroshi Shimamoto
Quoted 16 lines · Ingo Molnar
Quoted 13 lines · Hiroshi Shimamoto
From: Hiroshi Shimamoto <[email protected]>
Impact: fix
When
recursion_bugis true, kernel discards original message becauseprintk_bufcontainsrecursion_bug_msgwith NULL terminator. Thesizeof(recursion_bug_msg)makes this, usestrlen()to get correct length without NULL terminator.Reported-by Toshikazu Nakayama <[email protected]>Signed-off-by Hiroshi Shimamoto <[email protected]>--- kernel/printk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 8 lines
Quoted 5 lines
Good one - applied to tip/core/printk, thanks!
Btw., i'm curious: in what situation was such recursion observed, and how did the kernel behave? You saw a truncated recursion message in dmesg - or was it worse?
I'm not sure about the real situation. I've heard this issue was found in printing messages in NMI handler, maybe with artificial kernel stuck.
yeah, accidental NMI recursion back into printk could indeed cause the recursion message to pop up.
Ingo