linux-uconsole/drivers/firmware/efi
Jann Horn 86a926c3f0 pstore: Don't use semaphores in always-atomic-context code
commit 8126b1c731 upstream.

pstore_dump() is *always* invoked in atomic context (nowadays in an RCU
read-side critical section, before that under a spinlock).
It doesn't make sense to try to use semaphores here.

This is mostly a revert of commit ea84b580b9 ("pstore: Convert buf_lock
to semaphore"), except that two parts aren't restored back exactly as they
were:

 - keep the lock initialization in pstore_register
 - in efi_pstore_write(), always set the "block" flag to false
 - omit "is_locked", that was unnecessary since
   commit 959217c84c ("pstore: Actually give up during locking failure")
 - fix the bailout message

The actual problem that the buggy commit was trying to address may have
been that the use of preemptible() in efi_pstore_write() was wrong - it
only looks at preempt_count() and the state of IRQs, but __rcu_read_lock()
doesn't touch either of those under CONFIG_PREEMPT_RCU.
(Sidenote: CONFIG_PREEMPT_RCU means that the scheduler can preempt tasks in
RCU read-side critical sections, but you're not allowed to actively
block/reschedule.)

Lockdep probably never caught the problem because it's very rare that you
actually hit the contended case, so lockdep always just sees the
down_trylock(), not the down_interruptible(), and so it can't tell that
there's a problem.

Fixes: ea84b580b9 ("pstore: Convert buf_lock to semaphore")
Cc: stable@vger.kernel.org
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220314185953.2068993-1-jannh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08 14:39:56 +02:00
..
libstub riscv/efi_stub: Fix get_boot_hartid_from_fdt() return value 2022-03-08 19:09:31 +01:00
test efi_test: get rid of pointless access_ok() 2020-05-29 11:05:54 -04:00
apple-properties.c efi: fix return value of __setup handlers 2022-03-23 09:13:27 +01:00
arm-runtime.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
capsule-loader.c
capsule.c
cper-arm.c
cper-x86.c
cper.c efi/cper: use stack buffer for error record decoding 2021-10-20 11:45:00 +02:00
dev-path-parser.c
earlycon.c efi/earlycon: Fix early printk for wider fonts 2020-05-12 12:29:45 +02:00
efi-bgrt.c
efi-init.c efi: Support for MOK variable config table 2020-09-16 18:53:42 +03:00
efi-pstore.c pstore: Don't use semaphores in always-atomic-context code 2022-04-08 14:39:56 +02:00
efi.c efi: fix return value of __setup handlers 2022-03-23 09:13:27 +01:00
efibc.c efi: efibc: check for efivars write capability 2020-09-15 18:22:47 +03:00
efivars.c efi: efivars: limit availability to X86 builds 2020-09-29 19:40:57 +02:00
embedded-firmware.c test_firmware: Test platform fw loading on non-EFI systems 2020-09-10 18:19:16 +02:00
esrt.c efi/esrt: Fix reference count leak in esre_create_sysfs_entry. 2020-06-15 14:38:56 +02:00
fake_mem.c
fake_mem.h
fdtparams.c efi/fdt: fix panic when no valid fdt found 2021-06-10 13:39:13 +02:00
Kconfig efi: EFI_EARLYCON should depend on EFI 2020-11-25 16:55:02 +01:00
Makefile RISC-V Patches for the 5.10 Merge Window, Part 1 2020-10-19 18:18:30 -07:00
memattr.c efi: Allow EFI_MEMORY_XP and EFI_MEMORY_RO both to be cleared 2021-06-10 13:39:14 +02:00
memmap.c
mokvar-table.c efi/mokvar: Reserve the table only if it is in boot services data 2021-08-08 09:05:23 +02:00
rci2-table.c
reboot.c efi: Use EFI ResetSystem only when available 2020-02-23 21:59:42 +01:00
riscv-runtime.c RISC-V: Add EFI runtime services 2020-10-02 14:31:28 -07:00
runtime-map.c
runtime-wrappers.c efi: Change down_interruptible() in virt_efi_reset_system() to down_trylock() 2021-10-20 11:45:00 +02:00
tpm.c efi/tpm: Differentiate missing and invalid final event log table. 2021-07-28 14:35:38 +02:00
vars.c efivars: Respect "block" flag in efivar_entry_set_safe() 2022-03-08 19:09:35 +01:00
x86_fake_mem.c efi/fake_mem: arrange for a resource entry per efi_fake_mem instance 2020-10-13 18:38:27 -07:00