mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
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
This commit is contained in:
parent
d7e7b42f4f
commit
cf1a4cbce6
1 changed files with 19 additions and 0 deletions
|
@ -3938,6 +3938,25 @@ static struct btf_raw_test raw_tests[] = {
|
||||||
.btf_load_err = true,
|
.btf_load_err = true,
|
||||||
.err_str = "Invalid component_idx",
|
.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",
|
.descr = "type_tag test #1",
|
||||||
.raw_types = {
|
.raw_types = {
|
||||||
|
|
Loading…
Reference in a new issue