Skip to content

Commit a01009a

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]>
1 parent c74e2b2 commit a01009a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ __bpf_kfunc void bpf_testmod_ctx_release(struct bpf_testmod_ctx *ctx)
249249
call_rcu(&ctx->rcu, testmod_free_cb);
250250
}
251251

252+
__used __retain void __bpf_testmod_ctx_release(void *ctx)
253+
{
254+
bpf_testmod_ctx_release(ctx);
255+
}
256+
257+
CFI_NOSEAL(__bpf_testmod_ctx_release);
258+
252259
static struct bpf_testmod_ops3 *st_ops3;
253260

254261
static int bpf_testmod_test_3(void)
@@ -631,7 +638,7 @@ BTF_KFUNCS_END(bpf_testmod_common_kfunc_ids)
631638

632639
BTF_ID_LIST(bpf_testmod_dtor_ids)
633640
BTF_ID(struct, bpf_testmod_ctx)
634-
BTF_ID(func, bpf_testmod_ctx_release)
641+
BTF_ID(func, __bpf_testmod_ctx_release)
635642

636643
static const struct btf_kfunc_id_set bpf_testmod_common_kfunc_set = {
637644
.owner = THIS_MODULE,

0 commit comments

Comments
 (0)