linux/tools/include
Andrii Nakryiko 5f99f312bd bpf: add register bounds sanity checks and sanitization
Add simple sanity checks that validate well-formed ranges (min <= max)
across u64, s64, u32, and s32 ranges. Also for cases when the value is
constant (either 64-bit or 32-bit), we validate that ranges and tnums
are in agreement.

These bounds checks are performed at the end of BPF_ALU/BPF_ALU64
operations, on conditional jumps, and for LDX instructions (where subreg
zero/sign extension is probably the most important to check). This
covers most of the interesting cases.

Also, we validate the sanity of the return register when manually
adjusting it for some special helpers.

By default, sanity violation will trigger a warning in verifier log and
resetting register bounds to "unbounded" ones. But to aid development
and debugging, BPF_F_TEST_SANITY_STRICT flag is added, which will
trigger hard failure of verification with -EFAULT on register bounds
violations. This allows selftests to catch such issues. veristat will
also gain a CLI option to enable this behavior.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Link: https://lore.kernel.org/r/20231112010609.848406-5-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-11-15 12:03:42 -08:00
..
asm tools headers: Update the copy of x86's mem{cpy,set}_64.S used in 'perf bench' 2023-05-17 10:42:19 -03:00
asm-generic perf tools: Add get_unaligned_leNN() 2023-10-17 12:40:02 -07:00
io_uring selftests/net: Extract uring helpers to be reusable 2023-10-19 16:42:03 -06:00
linux As usual, lots of singleton and doubleton patches all over the tree and 2023-11-02 20:53:31 -10:00
nolibc tools/nolibc: add support for constructors and destructors 2023-10-12 21:14:16 +02:00
perf tools: Import arm_pmuv3.h 2023-10-24 22:59:30 +00:00
tools tools include: add dis-asm-compat.h to handle version differences 2022-08-01 15:29:49 -03:00
trace/events
uapi bpf: add register bounds sanity checks and sanitization 2023-11-15 12:03:42 -08:00
vdso tools headers: Synchronize {linux,vdso}/bits.h with the kernel sources 2023-03-03 22:34:15 -03:00