Commit cf3680b90c7842cf91ed857ac4528f4e057da366

Authored by Tejun Heo
Committed by Linus Torvalds
1 parent bfa274e243

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 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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -666,7 +666,7 @@
666 666 }
667 667 /* Emit the output into the temporary buffer */
668 668 printed_len += vscnprintf(printk_buf + printed_len,
669   - sizeof(printk_buf), fmt, args);
  669 + sizeof(printk_buf) - printed_len, fmt, args);
670 670  
671 671 /*
672 672 * Copy the output into log_buf. If the caller didn't provide