All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] bpf: fork state when comparing sign crossing ranges with zero
@ 2026-05-29  8:13 Eduard Zingerman
  2026-05-29  8:13 ` [PATCH bpf 1/2] " Eduard Zingerman
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Eduard Zingerman @ 2026-05-29  8:13 UTC (permalink / raw)
  To: bpf, ast
  Cc: andrii, daniel, martin.lau, kernel-team, yonghong.song, zhuyifei,
	Eduard Zingerman

YiFei Zhu reported [1] the verifier regression after switch to cnum
based scalars representation. When the following sequence of
instructions is processed:

    1: ... rX setup with [negative, positive] bounds ...
    2: if rX == 0 goto ...
    3: if rX > C  goto ...
    4: ... code relying on rX being in range [1, C] ...

The cnum-based implementation only infers that rX range is [0, C]
at instruction (4). The pre-cnum signed/unsigned ranges based
representation could always deduct from 'rX != 0' that
umin bound is 1.

This patch introduces a workaround forking the verifier state when a
register with sign-crossing range is compared to zero.

[1] https://lore.kernel.org/bpf/96c4a1aa4333d10b882a9b5093d2d982f9f106e3.camel@gmail.com/T/

---
Eduard Zingerman (2):
      bpf: fork state when comparing sign crossing ranges with zero
      selftests/bpf: test fork on zero comparison with wrapping ranges

 kernel/bpf/verifier.c                              | 71 ++++++++++++++++++++++
 .../testing/selftests/bpf/progs/verifier_bounds.c  | 68 +++++++++++++++++++++
 2 files changed, 139 insertions(+)
---
base-commit: e42e53ae23b7d41df22ccd7788192bf578f24da2
change-id: 20260529-cnum-split-at-zero-3c03db9234d3

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

end of thread, other threads:[~2026-06-10 11:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29  8:13 [PATCH bpf 0/2] bpf: fork state when comparing sign crossing ranges with zero Eduard Zingerman
2026-05-29  8:13 ` [PATCH bpf 1/2] " Eduard Zingerman
2026-05-29  8:58   ` bot+bpf-ci
2026-05-29 18:22     ` Eduard Zingerman
2026-05-29  8:59   ` sashiko-bot
2026-05-29 18:23     ` Eduard Zingerman
2026-05-29 16:57   ` Emil Tsalapatis
2026-05-29  8:13 ` [PATCH bpf 2/2] selftests/bpf: test fork on zero comparison with wrapping ranges Eduard Zingerman
2026-05-29 17:03   ` Emil Tsalapatis
2026-05-29 22:44 ` [PATCH bpf 0/2] bpf: fork state when comparing sign crossing ranges with zero Eduard Zingerman
2026-05-29 23:02   ` Ihor Solodrai
2026-05-29 23:53     ` Emil Tsalapatis
2026-06-10 11:07       ` Shung-Hsi Yu
2026-05-30  0:23   ` Eduard Zingerman
2026-05-30  0:43     ` Emil Tsalapatis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.