mirror of
https://github.com/torvalds/linux.git
synced 2026-11-28 01:13:11 +00:00
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 enabled. Signed-off-by: Sami Tolvanen <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
This commit is contained in:
committed by
Alexei Starovoitov
parent
ba7f1024a1
commit
99fde4d062
@@ -8846,6 +8846,13 @@ static int btf_check_dtor_kfuncs(struct btf *btf, const struct btf_id_dtor_kfunc
|
||||
*/
|
||||
if (!t || !btf_type_is_ptr(t))
|
||||
return -EINVAL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_CFI_CLANG)) {
|
||||
/* Ensure the destructor kfunc type matches btf_dtor_kfunc_t */
|
||||
t = btf_type_by_id(btf, t->type);
|
||||
if (!btf_type_is_void(t))
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user