aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_btf.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-02-28 15:31:21 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2019-03-01 01:31:47 +0100
commit8054d51f76c8da880115ffba6189b0efd7a5b5ba (patch)
treeb3c8c179f0c48a9592c5c3e5d3d72a23f60f81ae /tools/testing/selftests/bpf/test_btf.c
parenttools/libbpf: signedness bug in btf_dedup_ref_type() (diff)
downloadlinux-dev-8054d51f76c8da880115ffba6189b0efd7a5b5ba.tar.xz
linux-dev-8054d51f76c8da880115ffba6189b0efd7a5b5ba.zip
selftests/bpf: fix btf_dedup testing code
btf_dedup testing code doesn't account for length of struct btf_header when calculating the start of a string section. This patch fixes this problem. Fixes: 49b57e0d01db ("tools/bpf: remove btf__get_strings() superseded by raw data API") Signed-off-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Song Liu <songliubraving@fb.com> Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_btf.c')
-rw-r--r--tools/testing/selftests/bpf/test_btf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
index 02d314383a9c..1426c0a905c8 100644
--- a/tools/testing/selftests/bpf/test_btf.c
+++ b/tools/testing/selftests/bpf/test_btf.c
@@ -5936,9 +5936,9 @@ static int do_test_dedup(unsigned int test_num)
}
test_hdr = test_btf_data;
- test_strs = test_btf_data + test_hdr->str_off;
+ test_strs = test_btf_data + sizeof(*test_hdr) + test_hdr->str_off;
expect_hdr = expect_btf_data;
- expect_strs = expect_btf_data + expect_hdr->str_off;
+ expect_strs = expect_btf_data + sizeof(*test_hdr) + expect_hdr->str_off;
if (CHECK(test_hdr->str_len != expect_hdr->str_len,
"test_hdr->str_len:%u != expect_hdr->str_len:%u",
test_hdr->str_len, expect_hdr->str_len)) {