Skip to content

Commit ffcf4cc

Browse files
samitolvanenKernel Patches Daemon
authored andcommitted
selftests/bpf: Use the correct destructor kfunc type
With CONFIG_CFI enabled, the kernel strictly enforces that indirect function calls use a function pointer type that matches the target function. As bpf_testmod_ctx_release() signature differs from the btf_dtor_kfunc_t pointer type used for the destructor calls in bpf_obj_free_fields(), add a stub function with the correct type to fix the type mismatch. Signed-off-by: Sami Tolvanen <[email protected]> Acked-by: Yonghong Song <[email protected]>
1 parent 26b3c97 commit ffcf4cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/testing/selftests/bpf/test_kmods/bpf_testmod.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ __bpf_kfunc void bpf_testmod_ctx_release(struct bpf_testmod_ctx *ctx)
285285
call_rcu(&ctx->rcu, testmod_free_cb);
286286
}
287287

288+
__bpf_kfunc void bpf_testmod_ctx_release_dtor(void *ctx)
289+
{
290+
bpf_testmod_ctx_release(ctx);
291+
}
292+
CFI_NOSEAL(bpf_testmod_ctx_release_dtor);
293+
288294
static struct bpf_testmod_ops3 *st_ops3;
289295

290296
static int bpf_testmod_test_3(void)
@@ -707,7 +713,7 @@ BTF_KFUNCS_END(bpf_testmod_common_kfunc_ids)
707713

708714
BTF_ID_LIST(bpf_testmod_dtor_ids)
709715
BTF_ID(struct, bpf_testmod_ctx)
710-
BTF_ID(func, bpf_testmod_ctx_release)
716+
BTF_ID(func, bpf_testmod_ctx_release_dtor)
711717

712718
static const struct btf_kfunc_id_set bpf_testmod_common_kfunc_set = {
713719
.owner = THIS_MODULE,

0 commit comments

Comments
 (0)