Skip to content

Commit 452ad25

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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 7a75aae commit 452ad25

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7799,6 +7799,10 @@ static int process_timer_func(struct bpf_verifier_env *env, int regno,
77997799
verbose(env, "verifier bug. Two map pointers in a timer helper\n");
78007800
return -EFAULT;
78017801
}
7802+
if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
7803+
verbose(env, "bpf_timer cannot be used for PREEMPT_RT.\n");
7804+
return -EOPNOTSUPP;
7805+
}
78027806
meta->map_uid = reg->map_uid;
78037807
meta->map_ptr = map;
78047808
return 0;

0 commit comments

Comments
 (0)