selftests/bpf: Add test for reg2btf_ids out of bounds access
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Sun, 20 Feb 2022 02:31:38 +0000 (08:01 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 May 2022 15:22:34 +0000 (17:22 +0200)
commitf59e6886cafbd83ead79745f66ce6b7b3d47b2bc
treef860d2cc615ee8f877ff53ea5fb98805021222e3
parentdcecd95a135704b56b1b6b8a0e62136a99db712c
selftests/bpf: Add test for reg2btf_ids out of bounds access

commit 13c6a37d409db9abc9c0bfc6d0a2f07bf0fff60e upstream.

This test tries to pass a PTR_TO_BTF_ID_OR_NULL to the release function,
which would trigger a out of bounds access without the fix in commit
45ce4b4f9009 ("bpf: Fix crash due to out of bounds access into reg2btf_ids.")
but after the fix, it should only index using base_type(reg->type),
which should be less than __BPF_REG_TYPE_MAX, and also not permit any
type flags to be set for the reg->type.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220220023138.2224652-1-memxor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/bpf/verifier/calls.c