linux-stable/tools/testing
Alexei Starovoitov d03a5b00a3 bpf: Fix propagation of bounds from 64-bit min/max into 32-bit and var_off.
[ Upstream commit b9979db834 ]

Before this fix:
166: (b5) if r2 <= 0x1 goto pc+22
from 166 to 189: R2=invP(id=1,umax_value=1,var_off=(0x0; 0xffffffff))

After this fix:
166: (b5) if r2 <= 0x1 goto pc+22
from 166 to 189: R2=invP(id=1,umax_value=1,var_off=(0x0; 0x1))

While processing BPF_JLE the reg_set_min_max() would set true_reg->umax_value = 1
and call __reg_combine_64_into_32(true_reg).

Without the fix it would not pass the condition:
if (__reg64_bound_u32(reg->umin_value) && __reg64_bound_u32(reg->umax_value))

since umin_value == 0 at this point.
Before commit 10bf4e8316 the umin was incorrectly ingored.
The commit 10bf4e8316 fixed the correctness issue, but pessimized
propagation of 64-bit min max into 32-bit min max and corresponding var_off.

Fixes: 10bf4e8316 ("bpf: Fix propagation of 32 bit unsigned bounds from 64 bit bounds")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211101222153.78759-1-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-18 19:16:45 +01:00
..
fault-injection
ktest bootconfig/tracing/ktest: Update ktest example for boot-time tracing 2021-08-16 11:39:51 -04:00
kunit kunit: tool: better handling of quasi-bool args (--json, --raw_output) 2021-10-01 13:45:25 -06:00
nvdimm tools/testing/nvdimm: Fix missing 'fallthrough' warning 2021-08-11 11:55:54 -07:00
radix-tree idr test suite: Improve reporting from idr_find_test_1 2021-04-01 07:50:42 -04:00
scatterlist Merge branch 'akpm' (patches from Andrew) 2021-09-03 10:08:28 -07:00
selftests bpf: Fix propagation of bounds from 64-bit min/max into 32-bit and var_off. 2021-11-18 19:16:45 +01:00
vsock vsock_diag_test: remove free_sock_stat() call in test_no_sockets 2021-10-15 17:21:34 -07:00