diff options
| author | Daniel Xu <dxu@dxuuu.xyz> | 2025-01-14 13:28:44 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2025-01-16 17:51:10 -0800 |
| commit | 37cce22dbd51a3ef7f6c08c3fb5f1c5075a17fbb (patch) | |
| tree | 1a0a9958409ee4c9111c32ab6ea6c41b824692b3 /tools/testing/selftests/bpf/progs/uninit_stack.c | |
| parent | bpf: tcp: Mark bpf_load_hdr_opt() arg2 as read-write (diff) | |
| download | linux-37cce22dbd51a3ef7f6c08c3fb5f1c5075a17fbb.tar.gz linux-37cce22dbd51a3ef7f6c08c3fb5f1c5075a17fbb.zip | |
bpf: verifier: Refactor helper access type tracking
Previously, the verifier was treating all PTR_TO_STACK registers passed
to a helper call as potentially written to by the helper. However, all
calls to check_stack_range_initialized() already have precise access type
information available.
Rather than treat ACCESS_HELPER as a proxy for BPF_WRITE, pass
enum bpf_access_type to check_stack_range_initialized() to more
precisely track helper arguments.
One benefit from this precision is that registers tracked as valid
spills and passed as a read-only helper argument remain tracked after
the call. Rather than being marked STACK_MISC afterwards.
An additional benefit is the verifier logs are also more precise. For
this particular error, users will enjoy a slightly clearer message. See
included selftest updates for examples.
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/ff885c0e5859e0cd12077c3148ff0754cad4f7ed.1736886479.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/uninit_stack.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/uninit_stack.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/progs/uninit_stack.c b/tools/testing/selftests/bpf/progs/uninit_stack.c index 8a403470e557..046a204c8fc6 100644 --- a/tools/testing/selftests/bpf/progs/uninit_stack.c +++ b/tools/testing/selftests/bpf/progs/uninit_stack.c @@ -70,7 +70,8 @@ __naked int helper_uninit_to_misc(void *ctx) r1 = r10; \ r1 += -128; \ r2 = 32; \ - call %[bpf_trace_printk]; \ + r3 = 0; \ + call %[bpf_probe_read_user]; \ /* Call to dummy() forces print_verifier_state(..., true), \ * thus showing the stack state, matched by __msg(). \ */ \ @@ -79,7 +80,7 @@ __naked int helper_uninit_to_misc(void *ctx) exit; \ " : - : __imm(bpf_trace_printk), + : __imm(bpf_probe_read_user), __imm(dummy) : __clobber_all); } |
