]> www.infradead.org Git - linux.git/commit
selftests/bpf: Add three test cases for bits_iter
authorHou Tao <houtao1@huawei.com>
Wed, 30 Oct 2024 10:05:16 +0000 (18:05 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 30 Oct 2024 19:13:46 +0000 (12:13 -0700)
commitebafc1e535db19505aec3b94a4a641fe735a2eac
treefbf780dd9c3ca0a1197f6304c2a5a838c3f4ee40
parente1339383675063ae4760d81ffe13a79981841b8d
selftests/bpf: Add three test cases for bits_iter

Add more test cases for bits iterator:

(1) huge word test
Verify the multiplication overflow of nr_bits in bits_iter. Without
the overflow check, when nr_words is 67108865, nr_bits becomes 64,
causing bpf_probe_read_kernel_common() to corrupt the stack.
(2) max word test
Verify correct handling of maximum nr_words value (511).
(3) bad word test
Verify early termination of bits iteration when bits iterator
initialization fails.

Also rename bits_nomem to bits_too_big to better reflect its purpose.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20241030100516.3633640-6-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/verifier_bits_iter.c