bpf-next verifier regression on unsigned bound checking
I was looking at Kuniyuki's selftest for BPF autolowat [1], in particular why the verifier fails if these two conditions are swapped:
if (copy_len > RPC_DESC_SIZE)
goto disable; /* always false, only for verifier. */
if (copy_len == 0)
goto disable; /* FIN. */
This is the register trace of the reversed version (which fails verifier):
33: (71) r1 = *(u8 *)(r9 +16) ;
R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; 0xff)) R9=map_value(map=tcp_autolowat_m,ks=4,vs=20)
107: (b7) r7 = 8 ; R7=8
108: (1f) r7 -= r1 ;
R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; 0xff)) R7=scalar(smin=smin32=-247,smax=smax32=8)
117: (15) if r7 == 0x0 goto pc+48 ;
R7=scalar(smin=smin32=-247,smax=smax32=8)
118: (25) if r7 > 0x8 goto pc+47 ;
R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0; 0xf))
126: (bf) r4 = r7 ;
R4=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0; 0xf)) R7=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0; 0xf))
127: (85) call bpf_skb_load_bytes#26
R4 invalid zero-sized read: u64=[0,8]
The oddity happens at this instruction:
117: (15) if r7 == 0x0 goto pc+48 ;
R7=scalar(smin=smin32=-247,smax=smax32=8)
The C logic constrains that the unsigned copy_len != 0, and <= RPC_DESC_SIZE, i.e. the end state should be umin=1, umax=8. However instruction 117 does not record the umin constraint. If the checks are reversed to match the patch order, the verifier is sane; the possibility of overflow is eliminated, so the range becomes [0,8] after the first comparison, and then [1,8] after the second.
I looked at the verifier changes and found this commit:
commit bbc631085503a7fde9617be18b0657cc9a83910a
Author: Eduard Zingerman <[email protected]>
Date: Fri Apr 24 22:52:44 2026
bpf: replace min/max fields with struct cnum{32,64}This change means that the signed and unsigned ranges are no longer tracked separately, but rather in the same circular number. Unfortunately 0 falls within the circular range [-247, 8], and the cnum intersection returns the over-approximation result of the original R7 range (because the intersection happens on two disjoint arcs), thereby ignoring the introduced umin constraint.
I'm not sure how this could be fixed without reverting the patch of using cnum to track ranges (which would re-introduce a lot of maths :/ ), but I'm also not sure whether this is an acceptable regression. Some helpers, such as bpf_skb_load_bytes in the test, uses ARG_CONST_SIZE, which really does not like a zero lower bound. Therefore, if that argument results from a subtraction, the verifier now enforces checking the upper bound before the lower bound to eliminate underflows, even if the variable is unsigned and thus invokes no undefined behavior...
YiFei Zhu
eddyz87
maintainerQuoted 68 lines · YiFei Zhu
I was looking at Kuniyuki's selftest for BPF autolowat [1], in particular why the verifier fails if these two conditions are swapped:
if (
copy_len>RPC_DESC_SIZE)
goto disable; /* always false, only for verifier. */ if (copy_len== 0)
goto disable; /* FIN. */This is the register trace of the reversed version (which fails verifier):
33: (71) r1 = *(u8 *)(r9 +16) ; R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0;
0xff)) R9=map_value(map=tcp_autolowat_m,ks=4,vs=20)107: (b7) r7 = 8 ; R7=8
108: (1f) r7 -= r1 ; R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0;0xff)) R7=scalar(smin=smin32=-247,smax=smax32=8)117: (15) if r7 ==
0x0goto pc+48 ; R7=scalar(smin=smin32=-247,smax=smax32=8)
118: (25) if r7 >0x8goto pc+47 ; R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf))126: (bf) r4 = r7 ; R4=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;
0xf)) R7=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf))
127: (85) call bpf_skb_load_bytes#26
R4 invalid zero-sized read: u64=[0,8]The oddity happens at this instruction:
117: (15) if r7 ==
0x0goto pc+48 ;
R7=scalar(smin=smin32=-247,smax=smax32=8)The C logic constrains that the unsigned
copy_len!= 0, and <=RPC_DESC_SIZE, i.e. the end state should be umin=1, umax=8. However instruction 117 does not record the umin constraint. If the checks are reversed to match the patch order, the verifier is sane; the possibility of overflow is eliminated, so the range becomes [0,8] after the first comparison, and then [1,8] after the second.I looked at the verifier changes and found this commit:
commit
bbc631085503a7fde9617be18b0657cc9a83910a
Author: Eduard Zingerman <[email protected]>
Date: Fri Apr 24 22:52:44 2026bpf: replace min/max fields with struct cnum{32,64}
This change means that the signed and unsigned ranges are no longer tracked separately, but rather in the same circular number. Unfortunately 0 falls within the circular range [-247, 8], and the cnum intersection returns the over-approximation result of the original R7 range (because the intersection happens on two disjoint arcs), thereby ignoring the introduced umin constraint.
I'm not sure how this could be fixed without reverting the patch of using cnum to track ranges (which would re-introduce a lot of maths :/ ), but I'm also not sure whether this is an acceptable regression. Some helpers, such as
bpf_skb_load_bytesin the test, usesARG_CONST_SIZE, which really does not like a zero lower bound. Therefore, if that argument results from a subtraction, the verifier now enforces checking the upper bound before the lower bound to eliminate underflows, even if the variable is unsigned and thus invokes no undefined behavior...
Quoted 1 line
YiFei Zhu
That's unfortunate. Thank you for the detailed report.
One option is to allow intersect operation to return two intervals, then use both intervals and fork the verifier state to explore second half. Veristat impact to be measured.
Eduard Zingerman
maintainerQuoted 69 lines · On Tue, 2026-05-26 at 19:32 -0700, eddyz87 wrote:
Quoted 68 lines · YiFei Zhu
I was looking at Kuniyuki's selftest for BPF autolowat [1], in particular why the verifier fails if these two conditions are swapped:
if (
copy_len>RPC_DESC_SIZE)
goto disable; /* always false, only for verifier. */ if (copy_len== 0)
goto disable; /* FIN. */This is the register trace of the reversed version (which fails verifier):
33: (71) r1 = *(u8 *)(r9 +16) ; R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0;
0xff)) R9=map_value(map=tcp_autolowat_m,ks=4,vs=20)107: (b7) r7 = 8 ; R7=8
108: (1f) r7 -= r1 ; R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0;0xff)) R7=scalar(smin=smin32=-247,smax=smax32=8)117: (15) if r7 ==
0x0goto pc+48 ; R7=scalar(smin=smin32=-247,smax=smax32=8)
118: (25) if r7 >0x8goto pc+47 ; R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf))126: (bf) r4 = r7 ; R4=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;
0xf)) R7=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf))
127: (85) call bpf_skb_load_bytes#26
R4 invalid zero-sized read: u64=[0,8]The oddity happens at this instruction:
117: (15) if r7 ==
0x0goto pc+48 ;
R7=scalar(smin=smin32=-247,smax=smax32=8)The C logic constrains that the unsigned
copy_len!= 0, and <=RPC_DESC_SIZE, i.e. the end state should be umin=1, umax=8. However instruction 117 does not record the umin constraint. If the checks are reversed to match the patch order, the verifier is sane; the possibility of overflow is eliminated, so the range becomes [0,8] after the first comparison, and then [1,8] after the second.I looked at the verifier changes and found this commit:
commit
bbc631085503a7fde9617be18b0657cc9a83910a
Author: Eduard Zingerman <[email protected]>
Date: Fri Apr 24 22:52:44 2026bpf: replace min/max fields with struct cnum{32,64}
This change means that the signed and unsigned ranges are no longer tracked separately, but rather in the same circular number. Unfortunately 0 falls within the circular range [-247, 8], and the cnum intersection returns the over-approximation result of the original R7 range (because the intersection happens on two disjoint arcs), thereby ignoring the introduced umin constraint.
I'm not sure how this could be fixed without reverting the patch of using cnum to track ranges (which would re-introduce a lot of maths :/ ), but I'm also not sure whether this is an acceptable regression. Some helpers, such as
bpf_skb_load_bytesin the test, usesARG_CONST_SIZE, which really does not like a zero lower bound. Therefore, if that argument results from a subtraction, the verifier now enforces checking the upper bound before the lower bound to eliminate underflows, even if the variable is unsigned and thus invokes no undefined behavior...
Quoted 6 lines
Quoted 1 line
YiFei Zhu
That's unfortunate. Thank you for the detailed report.
One option is to allow intersect operation to return two intervals, then use both intervals and fork the verifier state to explore second half. Veristat impact to be measured.
A few notes on the pattern first. Here is an excerpt from the test case:
if (before(cb->rpc_desc_seq + RPC_DESC_SIZE, end_seq)) copy_len = RPC_DESC_SIZE - cb->rpc_desc_buff_len; else copy_len = end_seq - rpc_copied_seq; /* Since LLVM commit 324e27e8bad83ca23a3cd276d7e2e729b1b0b8c7, * clang omits the "copy_len == 0" check below, which is necessary * to satisfy the BPF verifier's range check for bpf_skb_load_bytes(). */ barrier_var(copy_len); /* Do not swap the order of the two copy_len checks below. * The BPF verifier somehow does not properly track the minimum * value for 'copy_len == 0'. * * 91: (15) if r7 == 0x0 goto pc+40 ; R7=scalar(smin=smin32=-247,smax=smax32=8) * 92: (25) if r7 > 0x8 goto pc+39 ; R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0; 0xf)) * * This does not occur if copy_len is u32. */ if (copy_len > RPC_DESC_SIZE) goto disable; /* always false, only for verifier. */ if (copy_len == 0) goto disable; /* FIN. */
Note that "do not swap" comment here is fragile, as clang is free to reorder these checks is at sees fit. It will pick the layout basing on branch probability assumptions, trying to maximize fallthrough.
The pattern in question looks as:
1: rX = ... some range crossing sign boundary ...
2: if rX == 0 goto ...
3: if rX > 8 goto ... // unsigned compare
4: ... here rX is guaranteed to be [1, 8] but verifier can't infer that ...
The (1) part is important, if rX is non-negative the cnums logic would infer true bounds. In the test case the negative range for copy_len comes from the arithmetic at the beginning of the code sample. I don't think such situations occur often.
The main difference from non-cnum verifier is that from rX != 0 it was always able to infer a umin bound of 1.
With this in mind I did two experiments:
- At each conditional jump, if cnumX_intersect in refine logic produces multiple arcs, fork the verifier state to represent each arc in it's own state ([1], horrible code quality but good enough for the experiment).
- At conditional jumps of form:
- rX == 0 / rX != 0
- or rX == rY / rX != rY where rY is known zero
- when rX is bounded and it's range crosses sign boundary Fork the verifier state splitting rX range in negative and non-negative parts ([2], patch is fine, tests need refinement).
[1] https://github.com/eddyz87/bpf/tree/cnum-intersect-split
[2] https://github.com/eddyz87/bpf/tree/cnum-split-at-zero
Approach [1] has some nasty verification performance regressions, because effectively it introduces a fork at each comparison with a constant. These compound when there are several comparisons within a for loop body. E.g. blowing up verification budget consumed by selftest test_parse_tcp_hdr_opt.c.
Approach [2] fixes the issue at hand and has almost no impact on verification performance when tested on a set of selftest/scx/meta/cilium programs.
It is fine tuning for a specific pattern though, but one might argue that zero is special and this behavior matches the pre-cnum umin logic.
I'm thinking about a somewhat more generic approach:
- a data flow pass collecting symbolic constraints on registers (e.g. rX != 0 ∧ rX <= 8 at instruction 4 in the pattern above);
- and using these constraints to:
- refine rX range during main verification pass
- deciding whether to call mark_chain_precision() on memory access by inspecting constraints (e.g. if constraint guarantees that rX <= 8 and memory access is safe when value is <= 8, there is no need to do mark_chain_precision()).
This might make sense if mark_chain_precision() part would result in measurable verification statistics improvements.
---
Of-course there is still an option to revert cnums altogether.
Quoted 105 lines · Eduard Zingerman
Quoted 69 lines · On Tue, 2026-05-26 at 19:32 -0700, eddyz87 wrote:
Quoted 68 lines · YiFei Zhu
I was looking at Kuniyuki's selftest for BPF autolowat [1], in particular why the verifier fails if these two conditions are swapped:
if (
copy_len>RPC_DESC_SIZE)
goto disable; /* always false, only for verifier. */
if (copy_len== 0)
goto disable; /* FIN. */This is the register trace of the reversed version (which fails verifier):
33: (71) r1 = *(u8 *)(r9 +16) ;
R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0;0xff)) R9=map_value(map=tcp_autolowat_m,ks=4,vs=20)107: (b7) r7 = 8 ; R7=8
108: (1f) r7 -= r1 ;
R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0;0xff)) R7=scalar(smin=smin32=-247,smax=smax32=8)117: (15) if r7 ==
0x0goto pc+48 ;
R7=scalar(smin=smin32=-247,smax=smax32=8)
118: (25) if r7 >0x8goto pc+47 ;
R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf))126: (bf) r4 = r7 ;
R4=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf)) R7=scalar(id=888,smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0;0xf))
127: (85) call bpf_skb_load_bytes#26
R4 invalid zero-sized read: u64=[0,8]The oddity happens at this instruction:
117: (15) if r7 ==
0x0goto pc+48 ;
R7=scalar(smin=smin32=-247,smax=smax32=8)The C logic constrains that the unsigned
copy_len!= 0, and <=RPC_DESC_SIZE, i.e. the end state should be umin=1, umax=8. However instruction 117 does not record the umin constraint. If the checks are reversed to match the patch order, the verifier is sane; the possibility of overflow is eliminated, so the range becomes [0,8] after the first comparison, and then [1,8] after the second.I looked at the verifier changes and found this commit:
commit
bbc631085503a7fde9617be18b0657cc9a83910a
Author: Eduard Zingerman <[email protected]>
Date: Fri Apr 24 22:52:44 2026bpf: replace min/max fields with struct cnum{32,64}This change means that the signed and unsigned ranges are no longer tracked separately, but rather in the same circular number. Unfortunately 0 falls within the circular range [-247, 8], and the cnum intersection returns the over-approximation result of the original R7 range (because the intersection happens on two disjoint arcs), thereby ignoring the introduced umin constraint.
I'm not sure how this could be fixed without reverting the patch of using cnum to track ranges (which would re-introduce a lot of maths :/ ), but I'm also not sure whether this is an acceptable regression. Some helpers, such as
bpf_skb_load_bytesin the test, usesARG_CONST_SIZE, which really does not like a zero lower bound. Therefore, if that argument results from a subtraction, the verifier now enforces checking the upper bound before the lower bound to eliminate underflows, even if the variable is unsigned and thus invokes no undefined behavior...Quoted 6 lines
Quoted 1 line
YiFei Zhu
That's unfortunate. Thank you for the detailed report.
One option is to allow intersect operation to return two intervals, then use both intervals and fork the verifier state to explore second half. Veristat impact to be measured.A few notes on the pattern first. Here is an excerpt from the test case:
if (before(cb->rpc_desc_seq + RPC_DESC_SIZE, end_seq)) copy_len = RPC_DESC_SIZE - cb->rpc_desc_buff_len; else copy_len = end_seq - rpc_copied_seq; /* Since LLVM commit 324e27e8bad83ca23a3cd276d7e2e729b1b0b8c7, * clang omits the "copy_len == 0" check below, which is necessary * to satisfy the BPF verifier's range check for bpf_skb_load_bytes(). */ barrier_var(copy_len); /* Do not swap the order of the two copy_len checks below. * The BPF verifier somehow does not properly track the minimum * value for 'copy_len == 0'. * * 91: (15) if r7 == 0x0 goto pc+40 ; R7=scalar(smin=smin32=-247,smax=smax32=8) * 92: (25) if r7 > 0x8 goto pc+39 ; R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=8,var_off=(0x0; 0xf)) * * This does not occur if copy_len is u32. */ if (copy_len > RPC_DESC_SIZE) goto disable; /* always false, only for verifier. */ if (copy_len == 0) goto disable; /* FIN. */
Quoted 3 lines
Note that "do not swap" comment here is fragile, as clang is free to reorder these checks is at sees fit. It will pick the layout basing on branch probability assumptions, trying to maximize fallthrough.
Right, good point.
Quoted 52 lines
The pattern in question looks as:
1: rX = ... some range crossing sign boundary ...
2: if rX == 0 goto ...
3: if rX > 8 goto ... // unsigned compare
4: ... here rX is guaranteed to be [1, 8] but verifier can't infer that ...The (1) part is important, if rX is non-negative the cnums logic would infer true bounds. In the test case the negative range for
copy_lencomes from the arithmetic at the beginning of the code sample. I don't think such situations occur often.The main difference from non-cnum verifier is that from
rX != 0it was always able to infer a umin bound of 1.With this in mind I did two experiments:
- At each conditional jump, ifcnumX_intersectin refine logic produces multiple arcs, fork the verifier state to represent each arc in it's own state ([1], horrible code quality but good enough for the experiment).
- At conditional jumps of form:
- rX == 0 / rX != 0
- or rX == rY / rX != rY where rY is known zero
- when rX is bounded and it's range crosses sign boundary Fork the verifier state splitting rX range in negative and non-negative parts ([2], patch is fine, tests need refinement).[1] https://github.com/eddyz87/bpf/tree/cnum-intersect-split
[2] https://github.com/eddyz87/bpf/tree/cnum-split-at-zeroApproach [1] has some nasty verification performance regressions, because effectively it introduces a fork at each comparison with a constant. These compound when there are several comparisons within a for loop body. E.g. blowing up verification budget consumed by selftest
test_parse_tcp_hdr_opt.c.Approach [2] fixes the issue at hand and has almost no impact on verification performance when tested on a set of selftest/scx/meta/cilium programs.
It is fine tuning for a specific pattern though, but one might argue that zero is special and this behavior matches the pre-cnum umin logic.I'm thinking about a somewhat more generic approach:
- a data flow pass collecting symbolic constraints on registers (e.g. rX != 0 ∧ rX <= 8 at instruction 4 in the pattern above);
- and using these constraints to:
- refine rX range during main verification pass
- deciding whether to callmark_chain_precision()on memory access by inspecting constraints (e.g. if constraint guarantees that rX <= 8 and memory access is safe when value is <= 8, there is no need to domark_chain_precision()).
Quoted 2 lines
This might make sense if
mark_chain_precision()part would result in measurable verification statistics improvements.
Thanks for the tests!
I personally think zero is special because of the signed bit, and ARG_CONST_SIZE. While the symbolic approach sounds ideal, I'm worried about the complexity of such a symbolic solver; checking if an if-condition is reachable could lead to a binary satisfiability problem. Of course, we could dumb down the symbolic solver, but the question now is how aggressively the solver should attempt to constrain the values, and I personally think constraining to ranges is fine.
YiFei Zhu
Quoted 3 lines
---
Of-course there is still an option to revert cnums altogether.
Quoted 6 lines · Eduard Zingerman
[2] https://github.com/eddyz87/bpf/tree/cnum-split-at-zero
Approach [2] fixes the issue at hand and has almost no impact on verification performance when tested on a set of selftest/scx/meta/cilium programs.
pls quantify "almost not impact" and send that patch. Looks small enough.
Eduard Zingerman
maintainerQuoted 10 lines · Alexei Starovoitov
Quoted 6 lines · Eduard Zingerman
[2] https://github.com/eddyz87/bpf/tree/cnum-split-at-zero
Approach [2] fixes the issue at hand and has almost no impact on verification performance when tested on a set of selftest/scx/meta/cilium programs.
pls quantify "almost not impact" and send that patch. Looks small enough.
Here are the stats comparing current master to this patch. Results are filtered by programs taking >= 10K instructions to verify.
========= selftests: master vs experiment2 =========
-rw-r--r-- 1 ezingerman users 504K May 28 03:21 selftests.master.veristat.csv -rw-r--r-- 1 ezingerman users 504K May 28 03:07 selftests.experiment2.veristat.csv
File Program Insns (A) Insns (B) Insns (DIFF) ---- ------- --------- --------- ------------
Total progs: 4707 Old success: 2952 New success: 2955 total_insns diff min: 0.00% total_insns diff max: 32.41%
0 -> value: 0
value -> 0: 0total_insns abs max old: 837,487total_insns abs max new: 837,487
0 .. 5 %: 4702 20 .. 30 %: 3 30 .. 35 %: 2
========= scx: master vs experiment2 =========
-rw-r--r-- 1 ezingerman users 38K May 28 03:22 scx.master.veristat.csv -rw-r--r-- 1 ezingerman users 38K May 28 03:07 scx.experiment2.veristat.csv
File Program Insns (A) Insns (B) Insns (DIFF) ---- ------- --------- --------- ------------
Total progs: 376 Old success: 351 New success: 351 total_insns diff min: 0.00% total_insns diff max: 0.00%
0 -> value: 0
value -> 0: 0total_insns abs max old: 233,696total_insns abs max new: 233,696
0 .. 5 %: 376
========= meta: master vs experiment2 =========
-rw-r--r-- 1 ezingerman users 234K May 28 03:28 meta.master.veristat.csv -rw-r--r-- 1 ezingerman users 234K May 28 03:14 meta.experiment2.veristat.csv
File Program Insns (A) Insns (B) Insns (DIFF) ---- ------- --------- --------- ------------
Total progs: 1540 Old success: 1448 New success: 1448 total_insns diff min: 0.00% total_insns diff max: 2.08%
0 -> value: 0
value -> 0: 0total_insns abs max old: 666,036total_insns abs max new: 666,036
0 .. 5 %: 1540
========= cilium: master vs experiment2 =========
-rw-r--r-- 1 ezingerman users 16K May 28 03:28 cilium.master.veristat.csv -rw-r--r-- 1 ezingerman users 16K May 28 03:14 cilium.experiment2.veristat.csv
File Program Insns (A) Insns (B) Insns (DIFF) --------------- --------------------------------- --------- --------- ------------- bpf_host.o tail_nodeport_nat_ingress_ipv4 19858 20170 +312 (+1.57%) bpf_lxc.o tail_nodeport_nat_ingress_ipv4 10510 11457 +947 (+9.01%) bpf_overlay.o tail_handle_inter_cluster_revsnat 10857 11437 +580 (+5.34%) bpf_overlay.o tail_nodeport_nat_ingress_ipv4 11768 12729 +961 (+8.17%) bpf_wireguard.o tail_nodeport_nat_ingress_ipv4 11811 12769 +958 (+8.11%)
Total progs: 134 Old success: 134 New success: 134 total_insns diff min: 0.00% total_insns diff max: 9.01%
0 -> value: 0
value -> 0: 0total_insns abs max old: 152,012total_insns abs max new: 152,012
0 .. 5 %: 130
5 .. 10 %: 4
Quoted 76 lines · Eduard Zingerman
Quoted 10 lines · Alexei Starovoitov
Quoted 6 lines · Eduard Zingerman
[2] https://github.com/eddyz87/bpf/tree/cnum-split-at-zero
Approach [2] fixes the issue at hand and has almost no impact on verification performance when tested on a set of selftest/scx/meta/cilium programs.
pls quantify "almost not impact" and send that patch. Looks small enough.
Here are the stats comparing current master to this patch. Results are filtered by programs taking >= 10K instructions to verify.
========= selftests: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 504K May 28 03:21 selftests.master.veristat.csv -rw-r--r-- 1 ezingerman users 504K May 28 03:07 selftests.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF) ---- ------- --------- --------- ------------Total progs: 4707 Old success: 2952 New success: 2955 total_insns diff min: 0.00% total_insns diff max: 32.41%0 -> value: 0
value -> 0: 0total_insnsabs max old: 837,487total_insnsabs max new: 837,4870 .. 5 %: 4702 20 .. 30 %: 3 30 .. 35 %: 2========= scx: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 38K May 28 03:22 scx.master.veristat.csv -rw-r--r-- 1 ezingerman users 38K May 28 03:07 scx.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF) ---- ------- --------- --------- ------------Total progs: 376 Old success: 351 New success: 351 total_insns diff min: 0.00% total_insns diff max: 0.00%0 -> value: 0
value -> 0: 0total_insnsabs max old: 233,696total_insnsabs max new: 233,696
0 .. 5 %: 376========= meta: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 234K May 28 03:28 meta.master.veristat.csv -rw-r--r-- 1 ezingerman users 234K May 28 03:14 meta.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF) ---- ------- --------- --------- ------------Total progs: 1540 Old success: 1448 New success: 1448 total_insns diff min: 0.00% total_insns diff max: 2.08%0 -> value: 0
value -> 0: 0total_insnsabs max old: 666,036total_insnsabs max new: 666,036
0 .. 5 %: 1540========= cilium: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 16K May 28 03:28 cilium.master.veristat.csv -rw-r--r-- 1 ezingerman users 16K May 28 03:14 cilium.experiment2.veristat.csv
Quoted 7 lines
File Program Insns (A) Insns (B) Insns (DIFF) --------------- --------------------------------- --------- --------- ------------- bpf_host.o tail_nodeport_nat_ingress_ipv4 19858 20170 +312 (+1.57%) bpf_lxc.o tail_nodeport_nat_ingress_ipv4 10510 11457 +947 (+9.01%) bpf_overlay.o tail_handle_inter_cluster_revsnat 10857 11437 +580 (+5.34%) bpf_overlay.o tail_nodeport_nat_ingress_ipv4 11768 12729 +961 (+8.17%) bpf_wireguard.o tail_nodeport_nat_ingress_ipv4 11811 12769 +958 (+8.11%)
ship it.
Eduard Zingerman
maintainerQuoted 75 lines · Alexei Starovoitov
Quoted 74 lines · Eduard Zingerman
Quoted 10 lines · Alexei Starovoitov
Quoted 6 lines · Eduard Zingerman
[2] https://github.com/eddyz87/bpf/tree/cnum-split-at-zero
Approach [2] fixes the issue at hand and has almost no impact on verification performance when tested on a set of selftest/scx/meta/cilium programs.
pls quantify "almost not impact" and send that patch. Looks small enough.
Here are the stats comparing current master to this patch. Results are filtered by programs taking >= 10K instructions to verify.
========= selftests: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 504K May 28 03:21 selftests.master.veristat.csv -rw-r--r-- 1 ezingerman users 504K May 28 03:07 selftests.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF)
---- ------- --------- --------- ------------Total progs: 4707
Old success: 2952
New success: 2955total_insnsdiff min: 0.00%total_insnsdiff max: 32.41%
0 -> value: 0
value -> 0: 0total_insnsabs max old: 837,487total_insnsabs max new: 837,487
0 .. 5 %: 4702
20 .. 30 %: 3
30 .. 35 %: 2========= scx: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 38K May 28 03:22 scx.master.veristat.csv -rw-r--r-- 1 ezingerman users 38K May 28 03:07 scx.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF)
---- ------- --------- --------- ------------Total progs: 376
Old success: 351
New success: 351total_insnsdiff min: 0.00%total_insnsdiff max: 0.00%
0 -> value: 0
value -> 0: 0total_insnsabs max old: 233,696total_insnsabs max new: 233,696
0 .. 5 %: 376========= meta: master vs experiment2 =========
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 234K May 28 03:28 meta.master.veristat.csv -rw-r--r-- 1 ezingerman users 234K May 28 03:14 meta.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF)
---- ------- --------- --------- ------------Total progs: 1540
Old success: 1448
New success: 1448total_insnsdiff min: 0.00%total_insnsdiff max: 2.08%
0 -> value: 0
value -> 0: 0total_insnsabs max old: 666,036total_insnsabs max new: 666,036
0 .. 5 %: 1540========= cilium: master vs experiment2 =========
Quoted 11 lines
Quoted 9 lines
(quoted diff) +0
-2-rw-r--r-- 1 ezingerman users 16K May 28 03:28 cilium.master.veristat.csv -rw-r--r-- 1 ezingerman users 16K May 28 03:14 cilium.experiment2.veristat.csvFile Program Insns (A) Insns (B) Insns (DIFF) --------------- --------------------------------- --------- --------- ------------- bpf_host.o tail_nodeport_nat_ingress_ipv4 19858 20170 +312 (+1.57%) bpf_lxc.o tail_nodeport_nat_ingress_ipv4 10510 11457 +947 (+9.01%) bpf_overlay.o tail_handle_inter_cluster_revsnat 10857 11437 +580 (+5.34%) bpf_overlay.o tail_nodeport_nat_ingress_ipv4 11768 12729 +961 (+8.17%) bpf_wireguard.o tail_nodeport_nat_ingress_ipv4 11811 12769 +958 (+8.11%)
ship it.
Ack, will send later today (closer or after midnight Pacific).