BPF List
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] bpf: Keep the valid bytes of a packet pointer in scalar evolution
@ 2026-10-27 20:14 Alexei Starovoitov
  2026-10-27 20:14 ` [PATCH bpf 1/2] " Alexei Starovoitov
  2026-10-27 20:14 ` [PATCH bpf 2/2] selftests/bpf: Test the valid bytes of a packet pointer in a counted loop Alexei Starovoitov
  0 siblings, 2 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2026-10-27 20:14 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, eddyz87, memxor

From: Alexei Starovoitov <ast@kernel.org>

Sashiko found a bug in the review of patch 14 of [1]. It is in the tree
since scalar evolution widens packet pointers.

'range - umax' bytes from a packet pointer are in the packet. At the head
of a counted loop scalar evolution sets new bounds, and reg_bounds_sync()
makes umax smaller: 58 becomes 56 when the step is 8. The range does not
change. Then the verifier accepts 2 bytes that are not in the packet.

  prog                               bpf tree  [1]    this fix
  ---------------------------------  --------  -----  --------
  r6 += 8, access in the loop        loads     loads  rejected
  r6 -= 8, access in the loop        loads     loads  rejected
  access in the second iteration     loads     loads  rejected

These patches apply on top of [1].

veristat shows the same verdicts and the same number of insns for all progs
of 36 weekly builds of Cilium (5032 progs), of sched-ext/scx (563 progs)
and of the selftests. test_progs, test_progs-no_alu32, test_progs-cpuv4,
test_progs-bpf_gcc and test_verifier have no new failure on x86-64.

[1] https://lore.kernel.org/bpf/20261027190314.1440199-1-alexei.starovoitov@gmail.com/

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Alexei Starovoitov (2):
  bpf: Keep the valid bytes of a packet pointer in scalar evolution
  selftests/bpf: Test the valid bytes of a packet pointer in a counted
    loop

 kernel/bpf/scev.c                             |   3 +
 kernel/bpf/verifier.c                         |  18 +-
 .../selftests/bpf/progs/verifier_scev.c       | 158 ++++++++++++++++++
 3 files changed, 177 insertions(+), 2 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-27 21:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 20:14 [PATCH bpf 0/2] bpf: Keep the valid bytes of a packet pointer in scalar evolution Alexei Starovoitov
2026-10-27 20:14 ` [PATCH bpf 1/2] " Alexei Starovoitov
2026-10-27 20:59   ` bot+bpf-ci
2026-10-27 21:04   ` sashiko-bot
2026-10-27 20:14 ` [PATCH bpf 2/2] selftests/bpf: Test the valid bytes of a packet pointer in a counted loop Alexei Starovoitov
2026-10-27 20:59   ` bot+bpf-ci
2026-10-27 20:59   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox