linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: fix discarding message when recursion_bug
@ 2008-12-19 18:23 Hiroshi Shimamoto
  2008-12-19 21:53 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Hiroshi Shimamoto @ 2008-12-19 18:23 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Toshikazu Nakayama, linux-kernel

From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

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.

Reported-by: Toshikazu Nakayama <nakayama.ts@ncos.nec.co.jp>
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
 kernel/printk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index f492f15..e651ab0 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -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,
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] printk: fix discarding message when recursion_bug
  2008-12-19 18:23 [PATCH] printk: fix discarding message when recursion_bug Hiroshi Shimamoto
@ 2008-12-19 21:53 ` Ingo Molnar
  2008-12-19 22:16   ` Hiroshi Shimamoto
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2008-12-19 21:53 UTC (permalink / raw)
  To: Hiroshi Shimamoto; +Cc: Toshikazu Nakayama, linux-kernel


* Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> wrote:

> From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> 
> 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.
> 
> Reported-by: Toshikazu Nakayama <nakayama.ts@ncos.nec.co.jp>
> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] printk: fix discarding message when recursion_bug
  2008-12-19 21:53 ` Ingo Molnar
@ 2008-12-19 22:16   ` Hiroshi Shimamoto
  2008-12-19 22:35     ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Hiroshi Shimamoto @ 2008-12-19 22:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Toshikazu Nakayama, linux-kernel

Ingo Molnar wrote:
> * Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> wrote:
> 
>> From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
>>
>> 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.
>>
>> Reported-by: Toshikazu Nakayama <nakayama.ts@ncos.nec.co.jp>
>> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
>> ---
>>  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?

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] printk: fix discarding message when recursion_bug
  2008-12-19 22:16   ` Hiroshi Shimamoto
@ 2008-12-19 22:35     ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2008-12-19 22:35 UTC (permalink / raw)
  To: Hiroshi Shimamoto; +Cc: Toshikazu Nakayama, linux-kernel


* Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> wrote:

> Ingo Molnar wrote:
> > * Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> wrote:
> > 
> >> From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> >>
> >> 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.
> >>
> >> Reported-by: Toshikazu Nakayama <nakayama.ts@ncos.nec.co.jp>
> >> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> >> ---
> >>  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?
> 
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-19 22:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-19 18:23 [PATCH] printk: fix discarding message when recursion_bug Hiroshi Shimamoto
2008-12-19 21:53 ` Ingo Molnar
2008-12-19 22:16   ` Hiroshi Shimamoto
2008-12-19 22:35     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).