diff options
| author | Sami Tolvanen <samitolvanen@google.com> | 2026-01-10 08:25:53 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-01-12 18:53:57 -0800 |
| commit | 99fde4d0626176d03cea35c64a063df73816e64d (patch) | |
| tree | 3c65cba3d151290533ab4213a03c3e8a90335ad6 /kernel/bpf | |
| parent | ba7f1024a1024f219a18c40b4ab2d7d900fd2d15 (diff) | |
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 <samitolvanen@google.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20260110082548.113748-10-samitolvanen@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf')
| -rw-r--r-- | kernel/bpf/btf.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 539c9fdea41d..2c6076fc29b9 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -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; } |
