diff options
| author | Eduard Zingerman <eddyz87@gmail.com> | 2026-08-31 18:36:10 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-09-02 11:13:21 -0700 |
| commit | 7ac9662189069914a088ec61ad85dc46b5cb1563 (patch) | |
| tree | c704c586a0296ed1b8a5f8aa4e24d3672f5a0c6d /scripts/Makefile.thinlto | |
| parent | e3e4f66cc4b72333d0886ae2673c360248987889 (diff) | |
| download | linux-7ac9662189069914a088ec61ad85dc46b5cb1563.tar.gz linux-7ac9662189069914a088ec61ad85dc46b5cb1563.zip | |
selftests/bpf: test case for unsafe pruning of bpf_loop checkpoints
The following BPF program was erroneously accepted by the verifier:
static int cb(int i, __u64 *ctx)
{
/* unsafe on a second iteration */
small_arr[*ctx] = i;
*ctx = 100500;
return 0;
}
int main(void *ctx)
{
int nr_loops = 1;
u64 ctx = 0;
if (unlikely(bpf_get_prandom_u32() == 42))
nr_loops = 2;
bpf_loop(nr_loops, cb, &ctx, 0);
return 0;
}
The branch with nr_loops == 1 was explored first and injected a
checkpoint at the entry to 'cb', such that nr_loops in the main's
frame was not marked as precise. This checkpoint pruned the state with
nr_loops == 2 and the program was accepted.
This test case corresponds to the program above.
Entry point is written in assembly to ensure branch processing order.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20260831-bug-015-backtrack-cb-args-precise-v1-2-68a8e2a821e0@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
