]> Gentwo Git Trees - linux/.git/commit
selftests/bpf: Test widen_imprecise_scalars() with different stack depth
authorEduard Zingerman <eddyz87@gmail.com>
Fri, 14 Nov 2025 02:57:30 +0000 (18:57 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 14 Nov 2025 17:26:28 +0000 (09:26 -0800)
commit6c762611fed7365790000925f3d14f20037d0061
treef41a07eb990173790ff87520fc7ee5b66600d0ba
parentb0c8e6d3d866b6a7f73877f71968dbffd27b7785
selftests/bpf: Test widen_imprecise_scalars() with different stack depth

A test case for a situation when widen_imprecise_scalars() is called
with old->allocated_stack > cur->allocated_stack. Test structure:

    def widening_stack_size_bug():
      r1 = 0
      for r6 in 0..1:
        iterator_with_diff_stack_depth(r1)
        r1 = 42

    def iterator_with_diff_stack_depth(r1):
      if r1 != 42:
        use 128 bytes of stack
      iterator based loop

iterator_with_diff_stack_depth() is verified with r1 == 0 first and
r1 == 42 next. Causing stack usage of 128 bytes on a first visit and 8
bytes on a second. Such arrangement triggered a KASAN error in
widen_imprecise_scalars().

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20251114025730.772723-2-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/iters_looping.c