]> xenbits.xensource.com Git - people/aperard/linux.git/commit
bpf: Avoid deadlock when using queue and stack maps from NMI
authorToke Høiland-Jørgensen <toke@redhat.com>
Mon, 11 Sep 2023 13:28:14 +0000 (15:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Oct 2023 19:46:36 +0000 (21:46 +0200)
commit40e34ea01748e5b8afdd40a172868be1e1ab0ede
tree10da3ca753e4d53e18c17256620092f244ac6cb6
parenteec981349b033a5a65b01cbc3cc039caa0790f8c
bpf: Avoid deadlock when using queue and stack maps from NMI

[ Upstream commit a34a9f1a19afe9c60ca0ea61dfeee63a1c2baac8 ]

Sysbot discovered that the queue and stack maps can deadlock if they are
being used from a BPF program that can be called from NMI context (such as
one that is attached to a perf HW counter event). To fix this, add an
in_nmi() check and use raw_spin_trylock() in NMI context, erroring out if
grabbing the lock fails.

Fixes: f1a2e44a3aec ("bpf: add queue and stack maps")
Reported-by: Hsin-Wei Hung <hsinweih@uci.edu>
Tested-by: Hsin-Wei Hung <hsinweih@uci.edu>
Co-developed-by: Hsin-Wei Hung <hsinweih@uci.edu>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20230911132815.717240-1-toke@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/queue_stack_maps.c