Re: [PATCH bpf-next v5 0/4] Use correct destructor kfunc types

From: Martin KaFai Lau

Date: Mon Jan 12 2026 - 15:33:36 EST


On 1/10/26 12:25 AM, Sami Tolvanen wrote:
Hi folks,

While running BPF self-tests with CONFIG_CFI (Control Flow
Integrity) enabled, I ran into a couple of failures in
bpf_obj_free_fields() caused by type mismatches between the
btf_dtor_kfunc_t function pointer type and the registered
destructor functions.

It looks like we can't change the argument type for these
functions to match btf_dtor_kfunc_t because the verifier doesn't
like void pointer arguments for functions used in BPF programs,
so this series fixes the issue by adding stubs with correct types
to use as destructors for each instance of this I found in the
kernel tree.

The last patch changes btf_check_dtor_kfuncs() to enforce the
function type when CFI is enabled, so we don't end up registering
destructors that panic the kernel.

Acked-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>