Commit b25b48c7 authored by Emil Tsalapatis's avatar Emil Tsalapatis Committed by Alexei Starovoitov
Browse files

bpf: Check active lock count in in_sleepable_context()



The in_sleepable_context() function is used to specialize the BPF code
in do_misc_fixups(). With the addition of nonsleepable arena kfuncs,
there are kfuncs whose specialization depends on whether we are
holding a lock. We should use the nonsleepable version while
holding a lock and the sleepable one when not.

Add a check for active_locks to account for locking when specializing
arena kfuncs.

Signed-off-by: default avatarEmil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260106-arena-under-lock-v2-1-378e9eab3066@etsalapatis.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent ea180ffb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11466,6 +11466,7 @@ static inline bool in_sleepable_context(struct bpf_verifier_env *env)
{
	return !env->cur_state->active_rcu_locks &&
	       !env->cur_state->active_preempt_locks &&
	       !env->cur_state->active_locks &&
	       !env->cur_state->active_irq_id &&
	       in_sleepable(env);
}