mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] printk: fix possible printk overrun
@ 2008-02-25 15:50 Ingo Molnar
  0 siblings, 0 replies; only message in thread
From: Ingo Molnar @ 2008-02-25 15:50 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel

Subject: printk: fix possible printk overrun
From: Tejun Heo <htejun@gmail.com>
Date: Thu, 14 Feb 2008 10:32:07 +0900

printk recursion detection prepends message to printk_buf and offsets 
printk_buf when actual message is printed but it forgets to trim buffer 
length accordingly. This can result in overrun in extreme cases. Fix it.

[ mingo@elte.hu:

  bug was introduced by me via:

   commit 32a76006683f7b28ae3cc491da37716e002f198e
   Author: Ingo Molnar <mingo@elte.hu>
   Date:   Fri Jan 25 21:07:58 2008 +0100

       printk: make printk more robust by not allowing recursion
]

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/printk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/kernel/printk.c
===================================================================
--- linux.orig/kernel/printk.c
+++ linux/kernel/printk.c
@@ -666,7 +666,7 @@ asmlinkage int vprintk(const char *fmt, 
 	}
 	/* Emit the output into the temporary buffer */
 	printed_len += vscnprintf(printk_buf + printed_len,
-				  sizeof(printk_buf), fmt, args);
+				  sizeof(printk_buf) - printed_len, fmt, args);
 
 	/*
 	 * Copy the output into log_buf.  If the caller didn't provide

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-25 15:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-25 15:50 [patch] printk: fix possible printk overrun Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®