Skip to content

Commit 3b2ec21

Browse files
Alexei Starovoitovanakryiko
authored andcommitted
selftests/bpf: Add light skeleton test for kfunc detection.
Add light skeleton test for kfunc detection and denylist it for s390. Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 708cdc5 commit 3b2ec21

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tools/testing/selftests/bpf/DENYLIST.s390x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ get_stack_raw_tp # user_stack corrupted user stack
1111
iters/testmod_seq* # s390x doesn't support kfuncs in modules yet
1212
kprobe_multi_bench_attach # bpf_program__attach_kprobe_multi_opts unexpected error: -95
1313
kprobe_multi_test # relies on fentry
14+
ksyms_btf/weak_ksyms* # test_ksyms_weak__open_and_load unexpected error: -22 (kfunc)
1415
ksyms_module # test_ksyms_module__open_and_load unexpected error: -9 (?)
1516
ksyms_module_libbpf # JIT does not support calling kernel function (kfunc)
1617
ksyms_module_lskel # test_ksyms_module_lskel__open_and_load unexpected error: -9 (?)

tools/testing/selftests/bpf/progs/test_ksyms_weak.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ __u64 out__non_existent_typed = -1;
2020
/* test existing weak symbols can be resolved. */
2121
extern const struct rq runqueues __ksym __weak; /* typed */
2222
extern const void bpf_prog_active __ksym __weak; /* typeless */
23+
struct task_struct *bpf_task_acquire(struct task_struct *p) __ksym __weak;
24+
void bpf_testmod_test_mod_kfunc(int i) __ksym __weak;
2325

2426

2527
/* non-existent weak symbols. */
@@ -29,6 +31,7 @@ extern const void bpf_link_fops1 __ksym __weak;
2931

3032
/* typed symbols, default to zero. */
3133
extern const int bpf_link_fops2 __ksym __weak;
34+
void invalid_kfunc(void) __ksym __weak;
3235

3336
SEC("raw_tp/sys_enter")
3437
int pass_handler(const void *ctx)
@@ -50,6 +53,18 @@ int pass_handler(const void *ctx)
5053
if (&bpf_link_fops2) /* can't happen */
5154
out__non_existent_typed = (__u64)bpf_per_cpu_ptr(&bpf_link_fops2, 0);
5255

56+
if (!bpf_ksym_exists(bpf_task_acquire))
57+
/* dead code won't be seen by the verifier */
58+
bpf_task_acquire(0);
59+
60+
if (!bpf_ksym_exists(bpf_testmod_test_mod_kfunc))
61+
/* dead code won't be seen by the verifier */
62+
bpf_testmod_test_mod_kfunc(0);
63+
64+
if (bpf_ksym_exists(invalid_kfunc))
65+
/* dead code won't be seen by the verifier */
66+
invalid_kfunc();
67+
5368
return 0;
5469
}
5570

0 commit comments

Comments
 (0)