]> git.baikalelectronics.ru Git - kernel.git/commit
printk: syslog: close window between wait and read
authorJohn Ogness <john.ogness@linutronix.de>
Thu, 15 Jul 2021 19:33:59 +0000 (21:39 +0206)
committerPetr Mladek <pmladek@suse.com>
Mon, 26 Jul 2021 13:09:57 +0000 (15:09 +0200)
commitc8c93aee907f824d1c2e39780360103e6271b869
tree20bd0d69f7541af943f6d197864d605423b58c87
parentee4d50fda40bc847a203da8b8b660d1fc195c733
printk: syslog: close window between wait and read

Syslog's SYSLOG_ACTION_READ is supposed to block until the next
syslog record can be read, and then it should read that record.
However, because @syslog_lock is not held between waking up and
reading the record, another reader could read the record first,
thus causing SYSLOG_ACTION_READ to return with a value of 0, never
having read _anything_.

By holding @syslog_lock between waking up and reading, it can be
guaranteed that SYSLOG_ACTION_READ blocks until it successfully
reads a syslog record (or a real error occurs).

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/20210715193359.25946-7-john.ogness@linutronix.de
kernel/printk/printk.c