bpf: fork state when comparing sign crossing ranges with zero
Get series with b4
b4 am [email protected] change-id 20260529-cnum-split-at-zero-3c03db9234d3Versions newest first
- v1 Latest2 patches 10 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: fork state when comparing sign crossing ranges with zerokernel/ | +71 | 3 replies | |
| 2/2 | selftests/bpf: test fork on zero comparison with wrapping rangestools/ | +68 | 1 reply |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Emil Tsalapatis |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf 0/2] bpf: fork state when comparing sign crossing ranges with zero
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/[email protected]/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