selftests/bpf: fix selftest after random:urandom_read tracepoint removal
Subsystems (3)
Andrii Nakryiko
maintainerPATCH 1/1 selftests/bpf: fix selftest after random:urandom_read tracepoint removal
14c174633f34 ("random: remove unused tracepoints") removed all the tracepoints from drivers/char/random.c, one of which, random:urandom_read, was used by stacktrace_build_id selftest to trigger stack trace capture from two different kernel code paths.
Fix breakage by switching to kprobing chacha_block_generic() function which is also called in both code paths that selftest uses for triggering.
--- tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +1 -1
@@ -47,7 +47,7 @@ struct random_urandom_args {int input_left; }; -SEC("tracepoint/random/urandom_read") +SEC("kprobe/chacha_block_generic")int oncpu (struct random_urandom_args *args) {__u32 max_len =sizeof (struct bpf_stack_build_id )
Signature · 1 line
2.30.2
Quoted 19 lines · Andrii Nakryiko
14c174633f34("random: remove unused tracepoints") removed all the tracepoints fromdrivers/char/random.c, one of which, random:urandom_read, was used bystacktrace_build_idselftest to trigger stack trace capture from two different kernel code paths.Fix breakage by switching to kprobing
chacha_block_generic()function which is also called in both code paths that selftest uses for triggering.Suggested-by Alexei Starovoitov <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>--- tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +0
-0
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c struct random_urandom_args { · line 50
Quoted 5 lines
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +1
-1@@ -47,7 +47,7 @@ struct random_urandom_args {int input_left; }; -SEC ("tracepoint/random/urandom_read" ) +SEC ("kprobe/chacha_block_generic" )
I tried this and it doesn't work in my environment. But changing to
SEC("kprobe/urandom_read")
works.
Also, if using kprobe, maybe rename 'struct random_urandom_args' to 'struct pt_regs'? Also, the struct random_urandom_args definition can be removed.
Quoted 3 lines
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +0
-0int oncpu (struct random_urandom_args *args) {__u32 max_len =sizeof (struct bpf_stack_build_id )
Quoted 26 lines · Yonghong Song
Quoted 22 lines · Andrii Nakryiko
14c174633f34("random: remove unused tracepoints") removed all the tracepoints fromdrivers/char/random.c, one of which, random:urandom_read, was used bystacktrace_build_idselftest to trigger stack trace capture from two different kernel code paths.Fix breakage by switching to kprobing
chacha_block_generic()function which is also called in both code paths that selftest uses for triggering.Suggested-by Alexei Starovoitov <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>--- tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +0
-0@@ -47,7 +47,7 @@ struct random_urandom_args {int input_left; };
Quoted 7 lines
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c struct random_urandom_args { · line 50
Quoted 2 lines
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +1
-1-SEC ("tracepoint/random/urandom_read" ) +SEC ("kprobe/chacha_block_generic" )I tried this and it doesn't work in my environment. But changing to
SEC("kprobe/urandom_read")
works.
I noticed flakiness locally as well. Switching to kprobe/urandom_read seems to work well, thanks!
Quoted 4 lines
Also, if using kprobe, maybe rename 'struct
random_urandom_args' to 'structpt_regs'? Also, the structrandom_urandom_argsdefinition can be removed.
yep, missed the need to clean this up. I'll send v2 shortly.
Quoted 4 lines
Quoted 4 lines
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c +0
-0int oncpu (struct random_urandom_args *args) {__u32 max_len =sizeof (struct bpf_stack_build_id )