OSDN Git Service

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)
commit8d909b2333f37e5da84a9e6a2cbe21f52be5f42a
tree20bd0d69f7541af943f6d197864d605423b58c87
parentb371cbb584d843bc4194d0cd4ce5ecd19b0cf55f
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