Skip to content

Commit 8c8508c

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 enabled. Signed-off-by: Sami Tolvanen <[email protected]> Acked-by: Yonghong Song <[email protected]>
1 parent ffcf4cc commit 8c8508c

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
@@ -8845,6 +8845,13 @@ static int btf_check_dtor_kfuncs(struct btf *btf, const struct btf_id_dtor_kfunc
88458845
*/
88468846
if (!t || !btf_type_is_ptr(t))
88478847
return -EINVAL;
8848+
8849+
if (IS_ENABLED(CONFIG_CFI_CLANG)) {
8850+
/* Ensure the destructor kfunc type matches btf_dtor_kfunc_t */
8851+
t = btf_type_by_id(btf, t->type);
8852+
if (!btf_type_is_void(t))
8853+
return -EINVAL;
8854+
}
88488855
}
88498856
return 0;
88508857
}

0 commit comments

Comments
 (0)