printk: fix cpu lock ordering
authorJohn Ogness <john.ogness@linutronix.de>
Thu, 17 Jun 2021 09:50:51 +0000 (11:56 +0206)
committerPetr Mladek <pmladek@suse.com>
Tue, 22 Jun 2021 07:57:15 +0000 (09:57 +0200)
commit3342aa8e6b4f6e3f1521e9b4cf5cfe50dbc37774
tree40f06e36bcbedf876fa6d3b8b1ebb2713ee7aec7
parent766c268bc6d39b8124e50d075a36b8a3305bc8e2
printk: fix cpu lock ordering

The cpu lock implementation uses a full memory barrier to take
the lock, but no memory barriers when releasing the lock. This
means that changes performed by a lock owner may not be seen by
the next lock owner. This may have been "good enough" for use
by dump_stack() as a serialization mechanism, but it is not
enough to provide proper protection for a critical section.

Correct this problem by using acquire/release memory barriers
for lock/unlock, respectively.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20210617095051.4808-3-john.ogness@linutronix.de
kernel/printk/printk.c