]> www.infradead.org Git - linux-platform-drivers-x86.git/commit
printk: limit second loop of syslog_print_all
authorJohn Ogness <john.ogness@linutronix.de>
Wed, 3 Mar 2021 10:15:16 +0000 (11:15 +0100)
committerPetr Mladek <pmladek@suse.com>
Mon, 8 Mar 2021 10:42:50 +0000 (11:42 +0100)
commitbb07b16c44b2c6ddbafa44bb06454719002e828e
tree5089091de3ff554808c411bd584f2d938a3f29a2
parent40ddbbac7f16eb91f9f2bbc414f283102052ce14
printk: limit second loop of syslog_print_all

The second loop of syslog_print_all() subtracts lengths that were
added in the first loop. With commit b031a684bfd0 ("printk: remove
logbuf_lock writer-protection of ringbuffer") it is possible that
records are (over)written during syslog_print_all(). This allows the
possibility of the second loop subtracting lengths that were never
added in the first loop.

This situation can result in syslog_print_all() filling the buffer
starting from a later record, even though there may have been room
to fit the earlier record(s) as well.

Fixes: b031a684bfd0 ("printk: remove logbuf_lock writer-protection of ringbuffer")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20210303101528.29901-4-john.ogness@linutronix.de
kernel/printk/printk.c