Skip to content

Commit d51c6b5

Browse files
Asphalttgregkh
authored andcommitted
bpf: Reject bpf_timer for PREEMPT_RT
[ Upstream commit e25ddfb ] When enable CONFIG_PREEMPT_RT, the kernel will warn when run timer selftests by './test_progs -t timer': BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 In order to avoid such warning, reject bpf_timer in verifier when PREEMPT_RT is enabled. Signed-off-by: Leon Hwang <leon.hwang@linux.dev> Link: https://lore.kernel.org/r/20250910125740.52172-2-leon.hwang@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9ebf862 commit d51c6b5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

kernel/bpf/verifier.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,6 +5071,10 @@ static int process_timer_func(struct bpf_verifier_env *env, int regno,
50715071
verbose(env, "verifier bug. Two map pointers in a timer helper\n");
50725072
return -EFAULT;
50735073
}
5074+
if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
5075+
verbose(env, "bpf_timer cannot be used for PREEMPT_RT.\n");
5076+
return -EOPNOTSUPP;
5077+
}
50745078
meta->map_uid = reg->map_uid;
50755079
meta->map_ptr = map;
50765080
return 0;

0 commit comments

Comments
 (0)