selftests/bpf: Fix invalid memory reads in core_relo selftest
authorAndrii Nakryiko <andriin@fb.com>
Wed, 29 Apr 2020 01:21:07 +0000 (18:21 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Apr 2020 02:48:05 +0000 (19:48 -0700)
Another one found by AddressSanitizer. input_len is bigger than actually
initialized data size.

Fixes: c7566a69695c ("selftests/bpf: Add field existence CO-RE relocs tests")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200429012111.277390-8-andriin@fb.com
tools/testing/selftests/bpf/prog_tests/core_reloc.c

index 31e177a..084ed26 100644 (file)
@@ -392,7 +392,7 @@ static struct core_reloc_test_case test_cases[] = {
                .input = STRUCT_TO_CHAR_PTR(core_reloc_existence___minimal) {
                        .a = 42,
                },
-               .input_len = sizeof(struct core_reloc_existence),
+               .input_len = sizeof(struct core_reloc_existence___minimal),
                .output = STRUCT_TO_CHAR_PTR(core_reloc_existence_output) {
                        .a_exists = 1,
                        .b_exists = 0,