Skip to content

Commit 26b3c97

Browse files
samitolvanenKernel Patches Daemon
authored andcommitted
bpf: net_sched: 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_kfree_skb() 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 916b82a commit 26b3c97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/sched/bpf_qdisc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ __bpf_kfunc void bpf_kfree_skb(struct sk_buff *skb)
202202
kfree_skb(skb);
203203
}
204204

205+
__bpf_kfunc void bpf_kfree_skb_dtor(void *skb)
206+
{
207+
bpf_kfree_skb(skb);
208+
}
209+
CFI_NOSEAL(bpf_kfree_skb_dtor);
210+
205211
/* bpf_qdisc_skb_drop - Drop an skb by adding it to a deferred free list.
206212
* @skb: The skb whose reference to be released and dropped.
207213
* @to_free_list: The list of skbs to be dropped.
@@ -449,7 +455,7 @@ static struct bpf_struct_ops bpf_Qdisc_ops = {
449455
.owner = THIS_MODULE,
450456
};
451457

452-
BTF_ID_LIST_SINGLE(bpf_sk_buff_dtor_ids, func, bpf_kfree_skb)
458+
BTF_ID_LIST_SINGLE(bpf_sk_buff_dtor_ids, func, bpf_kfree_skb_dtor)
453459

454460
static int __init bpf_qdisc_kfunc_init(void)
455461
{

0 commit comments

Comments
 (0)