diff options
author | Yonghong Song <yhs@fb.com> | 2022-02-03 11:17:32 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-02-03 13:06:04 -0800 |
commit | cf1a4cbce63b766d3b7aa5eb57a56d9a2c45ca6c (patch) | |
tree | 96a329a7e099c325022b6499c9ba8baf072b04fd /tools/testing/selftests | |
parent | d7e7b42f4f956f2c68ad8cda87d750093dbba737 (diff) | |
download | linux-cf1a4cbce63b766d3b7aa5eb57a56d9a2c45ca6c.tar.bz2 |
selftests/bpf: Add a selftest for invalid func btf with btf decl_tag
Added a selftest similar to [1] which exposed a kernel bug.
Without the fix in the previous patch, the similar kasan error will appear.
[1] https://lore.kernel.org/bpf/0000000000009b6eaa05d71a8c06@google.com/
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20220203191732.742285-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/btf.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c index 14f9b6136794..4038108aa499 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf.c +++ b/tools/testing/selftests/bpf/prog_tests/btf.c @@ -3939,6 +3939,25 @@ static struct btf_raw_test raw_tests[] = { .err_str = "Invalid component_idx", }, { + .descr = "decl_tag test #15, func, invalid func proto", + .raw_types = { + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ + BTF_DECL_TAG_ENC(NAME_TBD, 3, 0), /* [2] */ + BTF_FUNC_ENC(NAME_TBD, 8), /* [3] */ + BTF_END_RAW, + }, + BTF_STR_SEC("\0tag\0func"), + .map_type = BPF_MAP_TYPE_ARRAY, + .map_name = "tag_type_check_btf", + .key_size = sizeof(int), + .value_size = 4, + .key_type_id = 1, + .value_type_id = 1, + .max_entries = 1, + .btf_load_err = true, + .err_str = "Invalid type_id", +}, +{ .descr = "type_tag test #1", .raw_types = { BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ |