Skip to content

Commit 872b13b

Browse files
samitolvanenKernel Patches Daemon
authored andcommitted
bpf, btf: Enforce destructor kfunc type with CFI
Ensure that registered destructor kfuncs have the same type as btf_dtor_kfunc_t to avoid a kernel panic on systems with CONFIG_CFI_CLANG enabled. Signed-off-by: Sami Tolvanen <[email protected]> Acked-by: Yonghong Song <[email protected]>
1 parent b479cfa commit 872b13b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/bpf/btf.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8856,6 +8856,13 @@ static int btf_check_dtor_kfuncs(struct btf *btf, const struct btf_id_dtor_kfunc
88568856
*/
88578857
if (!t || !btf_type_is_ptr(t))
88588858
return -EINVAL;
8859+
8860+
if (IS_ENABLED(CONFIG_CFI_CLANG)) {
8861+
/* Ensure the destructor kfunc type matches btf_dtor_kfunc_t */
8862+
t = btf_type_by_id(btf, t->type);
8863+
if (!btf_type_is_void(t))
8864+
return -EINVAL;
8865+
}
88598866
}
88608867
return 0;
88618868
}

0 commit comments

Comments
 (0)