From: sashiko-bot@kernel.org
To: "Zhiling Zou" <zhilinz@nebusec.ai>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v2 1/1] ip: orphan prefetched skbs before multicast forwarding
Date: Fri, 07 Aug 2026 15:19:21 +0000 [thread overview]
Message-ID: <20260807151922.426151F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <f968f497251dedbd1263c322a7c4e3e1a727161d.1786023177.git.zhilinz@nebusec.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-After-Free (UAF) of `struct sock` on bridging and TC redirect paths due to non-refcounted sockets.
--
--- Patch [1]: [PATCH net v2 1/1] ip: orphan prefetched skbs before multicast forwarding ---
commit 8d7ee5d5781c74533a99f0b7cf5fb3db935e55f5
Author: Zhiling Zou <zhilinz@nebusec.ai>
ip: orphan prefetched skbs before multicast forwarding
This patch adds skb_orphan() calls before multicast forwarding in both
IPv4 and IPv6 to clear non-refcounted sockets assigned by bpf_sk_assign().
This prevents a use-after-free when the socket is destroyed before the
forwarded skb is freed.
Link: https://lore.kernel.org/all/02db4590d0161e31a789dcdfa8d1be1a3212ec2e.1785724784.git.zhilinz@nebusec.ai/
> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index 1d9a4ac14fcef..e5f2b1c6150d2 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -2213,6 +2213,9 @@ int ip_mr_input(struct sk_buff *skb)
> if (IPCB(skb)->flags & IPSKB_FORWARDED)
> goto dont_forward;
>
> + if (!local)
> + skb_orphan(skb);
> +
[Severity: High]
This isn't a bug introduced by this patch, but since you are fixing the
use-after-free for multicast forwarding, do we have the exact same problem
in the TC redirect and bridge forwarding paths?
If a packet receives a non-refcounted socket via bpf_sk_assign() at TC
ingress, and the eBPF program returns TC_ACT_REDIRECT, it is redirected
to an egress qdisc:
net/core/filter.c:skb_do_redirect() {
...
return __bpf_redirect(skb, dev, flags);
}
Alternatively, if it returns TC_ACT_OK and is processed by a bridge port,
it gets forwarded to an egress qdisc:
net/bridge/br_forward.c:br_forward() {
...
dev_queue_xmit(skb);
}
In both paths, skb_orphan() is not called, so the SKB retains the socket
pointer while sitting asynchronously in the qdisc. If the socket's RCU grace
period expires while queued, wouldn't a later free cause the exact same
use-after-free when the destructor dereferences the freed skb->sk?
net/core/sock.c:sock_pfree() {
struct sock *sk = skb->sk;
if (!sk_is_refcounted(sk))
return;
...
}
Should skb_orphan() be called before enqueuing to egress qdiscs in these
paths as well?
> mrt = ipmr_rt_fib_lookup(net, skb);
> if (IS_ERR(mrt)) {
> kfree_skb(skb);
--
Sashiko AI review · https://sashiko.dev/#/patchset/f968f497251dedbd1263c322a7c4e3e1a727161d.1786023177.git.zhilinz@nebusec.ai?part=1
prev parent reply other threads:[~2026-08-07 15:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 15:18 [PATCH net v2 1/1] ip: orphan prefetched skbs before multicast forwarding Zhiling Zou
2026-08-07 15:19 ` sashiko-bot [this message]
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=20260807151922.426151F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhilinz@nebusec.ai \
/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