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/verifier_raw_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/verifier_raw_stack.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/verifier_raw_stack.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/progs/verifier_raw_stack.c b/tools/testing/selftests/bpf/progs/verifier_raw_stack.c index 7cc83acac727..c689665e07b9 100644 --- a/tools/testing/selftests/bpf/progs/verifier_raw_stack.c +++ b/tools/testing/selftests/bpf/progs/verifier_raw_stack.c @@ -236,7 +236,7 @@ __naked void load_bytes_spilled_regs_data(void) SEC("tc") __description("raw_stack: skb_load_bytes, invalid access 1") -__failure __msg("invalid indirect access to stack R3 off=-513 size=8") +__failure __msg("invalid write to stack R3 off=-513 size=8") __naked void load_bytes_invalid_access_1(void) { asm volatile (" \ @@ -255,7 +255,7 @@ __naked void load_bytes_invalid_access_1(void) SEC("tc") __description("raw_stack: skb_load_bytes, invalid access 2") -__failure __msg("invalid indirect access to stack R3 off=-1 size=8") +__failure __msg("invalid write to stack R3 off=-1 size=8") __naked void load_bytes_invalid_access_2(void) { asm volatile (" \ |
