Skip to content

Commit d8e20da

Browse files
author
CKI KWF Bot
committed
Merge: bpf: Reject bpf_timer for PREEMPT_RT
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7405 JIRA: https://issues.redhat.com/browse/RHEL-83826 Omitted-fix: f7528e4 ("selftests/bpf: Skip timer cases when bpf_timer is not supported") - The fix skips a selftest introduced in 88a3bde ("selftests/bpf: Add case to test bpf_in_interrupt()") which has not been backported. Selftests cause kernel hang on RT kernels due to bpf_timer. This patch rejects bpf_timer usage in the verifier when PREEMPT_RT is enabled, and skips the corresponding timer selftests. Signed-off-by: Gregory Bell <grbell@redhat.com> Approved-by: Viktor Malik <vmalik@redhat.com> Approved-by: Jerome Marchand <jmarchan@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 3bbdea0 + d40a64e commit d8e20da

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7779,6 +7779,10 @@ static int process_timer_func(struct bpf_verifier_env *env, int regno,
77797779
verbose(env, "verifier bug. Two map pointers in a timer helper\n");
77807780
return -EFAULT;
77817781
}
7782+
if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
7783+
verbose(env, "bpf_timer cannot be used for PREEMPT_RT.\n");
7784+
return -EOPNOTSUPP;
7785+
}
77827786
meta->map_uid = reg->map_uid;
77837787
meta->map_ptr = map;
77847788
return 0;

tools/testing/selftests/bpf/prog_tests/free_timer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ void test_free_timer(void)
124124
int err;
125125

126126
skel = free_timer__open_and_load();
127+
if (!skel && errno == EOPNOTSUPP) {
128+
test__skip();
129+
return;
130+
}
127131
if (!ASSERT_OK_PTR(skel, "open_load"))
128132
return;
129133

tools/testing/selftests/bpf/prog_tests/timer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ void serial_test_timer(void)
8686
int err;
8787

8888
timer_skel = timer__open_and_load();
89+
if (!timer_skel && errno == EOPNOTSUPP) {
90+
test__skip();
91+
return;
92+
}
8993
if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load"))
9094
return;
9195

tools/testing/selftests/bpf/prog_tests/timer_crash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ static void test_timer_crash_mode(int mode)
1212
struct timer_crash *skel;
1313

1414
skel = timer_crash__open_and_load();
15+
if (!skel && errno == EOPNOTSUPP) {
16+
test__skip();
17+
return;
18+
}
1519
if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load"))
1620
return;
1721
skel->bss->pid = getpid();

tools/testing/selftests/bpf/prog_tests/timer_lockup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ void test_timer_lockup(void)
5959
}
6060

6161
skel = timer_lockup__open_and_load();
62+
if (!skel && errno == EOPNOTSUPP) {
63+
test__skip();
64+
return;
65+
}
6266
if (!ASSERT_OK_PTR(skel, "timer_lockup__open_and_load"))
6367
return;
6468

tools/testing/selftests/bpf/prog_tests/timer_mim.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ void serial_test_timer_mim(void)
6565
goto cleanup;
6666

6767
timer_skel = timer_mim__open_and_load();
68+
if (!timer_skel && errno == EOPNOTSUPP) {
69+
test__skip();
70+
return;
71+
}
6872
if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load"))
6973
goto cleanup;
7074

0 commit comments

Comments
 (0)