diff options
| author | Eduard Zingerman <eddyz87@gmail.com> | 2026-10-09 03:47:25 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-10-09 20:29:12 +0000 |
| commit | c6477be1580445be005c8c249f00fc44eeca3190 (patch) | |
| tree | a1dde86e22a08a4fa49e87990b962fa78ba3380c /kernel | |
| parent | 30175f5d9b1a82e6664485bfe9e50e4dcaa6f2ac (diff) | |
| download | linux-next-c6477be1580445be005c8c249f00fc44eeca3190.tar.gz linux-next-c6477be1580445be005c8c249f00fc44eeca3190.zip | |
bpf: Summarize regs that may hold a frame pointer in insn_aux_data
SCEV needs to know which registers might be stack pointers at a
particular instruction. This information is used to avoid widening
registers if that would hinder further verification.
See the patch [1] for additional information.
liveness.c:compute_subprog_args() already tracks this information.
This commit modifies it to save the information in insn_aux_data for
further usage.
[1] "bpf: avoid widening registers that hinder exact stack-slot tracking"
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261009-scev-minimal-rebase-v3-7-bcba9bc53ac9@gmail.com
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/bpf/liveness.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/bpf/liveness.c b/kernel/bpf/liveness.c index 004c1f48a065..b9b76684906e 100644 --- a/kernel/bpf/liveness.c +++ b/kernel/bpf/liveness.c @@ -1896,6 +1896,17 @@ static void print_subprog_arg_access(struct bpf_verifier_env *env, } } +static void record_stack_ptrs(struct bpf_verifier_env *env, int idx, struct arg_track *at_in) +{ + u16 r, mask = 0; + + for (r = 0; r < MAX_BPF_REG; r++) + if (arg_is_fp(&at_in[r])) + mask |= BIT(r); + + env->insn_aux_data[idx].stack_ptrs |= mask; +} + /* * Compute arg tracking dataflow for a single subprog. * Runs forward fixed-point with arg_track_xfer(), then records @@ -2045,6 +2056,8 @@ redo: snap->slots = nslots; memcpy(snap->at, &at_stack_in[(size_t)i * nslots], nslots * sizeof(*snap->at)); } + + record_stack_ptrs(env, idx, at_in[i]); } info->at_in = at_in; |
