Skip to content

Commit b479cfa

Browse files
samitolvanenKernel Patches Daemon
authored andcommitted
selftests/bpf: Use the correct destructor kfunc type
With CONFIG_CFI_CLANG 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 13a9157 commit b479cfa

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
@@ -249,6 +249,12 @@ __bpf_kfunc void bpf_testmod_ctx_release(struct bpf_testmod_ctx *ctx)
249249
call_rcu(&ctx->rcu, testmod_free_cb);
250250
}
251251

252+
__bpf_kfunc void bpf_testmod_ctx_release_dtor(void *ctx)
253+
{
254+
bpf_testmod_ctx_release(ctx);
255+
}
256+
CFI_NOSEAL(bpf_testmod_ctx_release_dtor);
257+
252258
static struct bpf_testmod_ops3 *st_ops3;
253259

254260
static int bpf_testmod_test_3(void)
@@ -631,7 +637,7 @@ BTF_KFUNCS_END(bpf_testmod_common_kfunc_ids)
631637

632638
BTF_ID_LIST(bpf_testmod_dtor_ids)
633639
BTF_ID(struct, bpf_testmod_ctx)
634-
BTF_ID(func, bpf_testmod_ctx_release)
640+
BTF_ID(func, bpf_testmod_ctx_release_dtor)
635641

636642
static const struct btf_kfunc_id_set bpf_testmod_common_kfunc_set = {
637643
.owner = THIS_MODULE,

0 commit comments

Comments
 (0)