Commit cf3680b9 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

printk: fix possible printk overrun

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 32a76006
   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: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bfa274e2
...@@ -666,7 +666,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -666,7 +666,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
} }
/* Emit the output into the temporary buffer */ /* Emit the output into the temporary buffer */
printed_len += vscnprintf(printk_buf + printed_len, 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 * Copy the output into log_buf. If the caller didn't provide
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment