From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf v2] bpf: net_sched: Let bpf_kfree_skb() run with irqs off
Date: Mon, 23 Nov 2026 20:16:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-229982@kernel.org> (raw)
In-Reply-To: <a2d4276cbf11b1254aa7997874a6539d20f296cf.1795463894.git.memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] bpf: net_sched: bpf_kfree_skb() calls kfree_skb_reason() when
non-preemptible
--
commit b478044d031a8f9f97373bdfc829434fc4dd56c2
Author: Alexei Starovoitov <ast@kernel.org>
bpf: net_sched: Let bpf_kfree_skb() run with irqs off
This commit switches bpf_kfree_skb() from kfree_skb() to
dev_kfree_skb_any() so that skb kptr destructors can run when interrupts
are disabled.
> diff --git a/net/sched/bpf_qdisc.c b/net/sched/bpf_qdisc.c
> index 5691c13781a8b..e041383a848f2 100644
> --- a/net/sched/bpf_qdisc.c
> +++ b/net/sched/bpf_qdisc.c
> @@ -196,10 +196,13 @@ __bpf_kfunc u32 bpf_skb_get_hash(struct sk_buff *skb)
>
> /* bpf_kfree_skb - Release an skb's reference and drop it immediately.
> * @skb: The skb whose reference to be released and dropped.
> + *
> + * Also the destructor of an skb kptr, which runs wherever an object or a map
> + * value with such a field is freed: under a bpf_spin_lock too, with irqs off.
> */
> __bpf_kfunc void bpf_kfree_skb(struct sk_buff *skb)
> {
> - kfree_skb(skb);
> + dev_kfree_skb_any(skb);
> }
[Severity: Medium]
Can bpf_kfree_skb() still call kfree_skb_reason() while preemption is
disabled with interrupts enabled?
dev_kfree_skb_any_reason() only defers freeing when in_hardirq() ||
irqs_disabled(). A BPF list or rbtree can be protected by
bpf_res_spin_lock, which disables preemption and acquires a raw
rqspinlock_t without disabling interrupts (unlike bpf_spin_lock or
bpf_res_spin_lock_irqsave). If bpf_list_add() fails while holding
bpf_res_spin_lock, __bpf_list_add() drops the node and invokes
bpf_kfree_skb_dtor() -> bpf_kfree_skb() with preemption disabled and IRQs
enabled (or a program can call bpf_kfree_skb() inside a
bpf_preempt_disable() section).
dev_kfree_skb_any() then takes the synchronous kfree_skb_reason() path,
which on PREEMPT_RT can acquire sleeping locks (spinlock_t or local_lock)
inside the skb destructor or allocator while non-preemptible and holding
a raw spinlock. On non-PREEMPT_RT, if bpf_res_spin_lock() is taken in
process context, an skb destructor doing local_bh_enable() can also run
pending softirqs under the raw rqspinlock_t.
--
Sashiko AI review · https://sashiko.dev/#/patchset/a2d4276cbf11b1254aa7997874a6539d20f296cf.1795463894.git.memxor@gmail.com?part=1
next prev parent reply other threads:[~2026-11-23 20:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 19:58 [PATCH bpf v2] bpf: net_sched: Let bpf_kfree_skb() run with irqs off Kumar Kartikeya Dwivedi
2026-11-23 20:16 ` sashiko-bot [this message]
2026-11-23 20:33 ` bot+bpf-ci
2026-11-24 6:32 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-229982@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox