]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: Consolidate sleepable checks in check_func_call()
authorPuranjay Mohan <puranjay@kernel.org>
Wed, 18 Mar 2026 17:43:26 +0000 (10:43 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 21 Mar 2026 20:09:35 +0000 (13:09 -0700)
commita2542a91aafd5fcf20cd804cd14c9de52cfc397e
tree2e2b3004dac05ebdb390fcb7ccf5a4bdd6490141
parentcd9840c413e3280d1c944e2e7e67380bc9a862d1
bpf: Consolidate sleepable checks in check_func_call()

The sleepable context check for global function calls in
check_func_call() open-codes the same checks that in_sleepable_context()
already performs. Replace the open-coded check with a call to
in_sleepable_context() and use non_sleepable_context_description() for
the error message, consistent with check_helper_call() and
check_kfunc_call().

Note that in_sleepable_context() also checks active_locks, which
overlaps with the existing active_locks check above it. However, the two
checks serve different purposes: the active_locks check rejects all
global function calls while holding a lock (not just sleepable ones), so
it must remain as a separate guard.

Update the expected error messages in the irq and preempt_lock selftests
to match.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20260318174327.3151925-4-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c
tools/testing/selftests/bpf/progs/irq.c
tools/testing/selftests/bpf/progs/preempt_lock.c