From: Paolo Abeni <pabeni@redhat.com>
To: almasrymina@google.com
Cc: kuba@kernel.org, kaiyuanz@google.com, willemb@google.com,
edumazet@google.com, pabeni@redhat.com, sdf@fomichev.me,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
dev@openvswitch.org, davem@davemloft.net, horms@kernel.org,
ncardwell@google.com, kuniyu@google.com, aconole@redhat.com,
echaudro@redhat.com, i.maximets@ovn.org,
kerneljasonxing@gmail.com, asml.silence@gmail.com,
bobbyeshleman@gmail.com, fw@strlen.de
Subject: Re: [PATCH net v4 1/2] net: core: propagate unreadable flag in skb_zerocopy
Date: Tue, 18 Aug 2026 12:25:57 +0200 [thread overview]
Message-ID: <20260818102557.132214-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260814191336.187243-1-almasrymina@google.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: core: propagate unreadable flag in skb_zerocopy
The patch makes skb_zerocopy() propagate the unreadable flag to the
destination skb, returns -EFAULT when a readable head payload would be
mixed with unreadable frags, and rejects unreadable skbs in openvswitch
queue_userspace_packet().
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index ba3dbac80fb49..d21af68156950 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
[ ... ]
> @@ -3905,10 +3906,17 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
> }
> }
>
> + if (!skb_frags_readable(from) && j > 0 && len) {
> + put_page(virt_to_head_page(from->head));
> + return -EFAULT;
> + }
> +
> skb_len_add(to, len + plen);
>
> if (unlikely(skb_orphan_frags(from, GFP_ATOMIC))) {
> skb_tx_error(from);
> + if (j > 0)
> + put_page(virt_to_head_page(from->head));
> return -ENOMEM;
> }
[Severity: Medium]
On this -ENOMEM path, is it safe to re-derive the head page from
from->head after skb_orphan_frags() has already run?
skb_orphan_frags() -> skb_copy_ubufs() drops the clone first:
net/core/skbuff.c:skb_copy_ubufs() {
...
if (skb_shared(skb) || skb_unclone(skb, gfp_mask))
return -EINVAL;
...
page = alloc_pages(gfp_mask | __GFP_COMP, order);
if (!page) {
...
return -ENOMEM;
}
}
and skb_unclone() -> pskb_expand_head() replaces the buffer:
net/core/skbuff.c:pskb_expand_head() {
...
skb->head = data;
skb->head_frag = 0;
...
}
So when the -ENOMEM comes from the alloc_pages() loop, from->head can
already point at a different (freshly allocated) buffer than the page that
was get_page()'d earlier in the hlen == 0 branch:
page = virt_to_head_page(from->head);
offset = from->data - (unsigned char *)page_address(page);
__skb_fill_netmem_desc(to, 0, page_to_netmem(page), offset, plen);
get_page(page);
j = 1;
Does that leak the reference on the original head-fragment page, and apply
the put_page() to an unrelated buffer? Today the misdirected put_page() is
quiet because pskb_expand_head() installs slab/kmalloc memory and put_page()
early-returns for folio_test_slab()/folio_test_large_kmalloc() folios, but
the reference on the page that was actually taken is never returned.
Would it be more robust to keep the page pointer captured before get_page()
in a local and use put_page(page) in both new error paths?
I was not able to find an in-tree producer that combines head_frag == 1 with
skb_zcopy() set, so this path may not be reachable today.
[Severity: Low]
This hunk looks like it also fixes an older, unrelated head-page reference
leak. __skb_fill_netmem_desc() does not bump skb_shinfo(to)->nr_frags:
include/linux/skbuff.h:__skb_fill_netmem_desc() {
__skb_fill_netmem_desc_noacc(skb_shinfo(skb), i, netmem, off, size);
...
}
and skb_zerocopy() only sets it at the very end with
skb_shinfo(to)->nr_frags = j;. So before this patch, returning -ENOMEM here
left @to with nr_frags == 0 and the extra head-page reference was never
dropped when the caller freed it (consume_skb(user_skb) in
queue_userspace_packet(), kfree_skb() in nfqnl_build_packet_message()).
That leak dates back to 36d5fe6a0007 ("core, nfqueue, openvswitch: Orphan
frags in skb_zerocopy and handle errors") and is unrelated to unreadable
frags, while the changelog only mentions unreadable-flag propagation and the
new -EFAULT returns, and the Fixes: tag points at 65249feb6b3d.
Could this hunk be split into its own patch with Fixes: 36d5fe6a0007, or at
least described in the commit message, so that stable backports reach the
pre-6.12 kernels that also contain the leak?
> + if (i > 0 && from->unreadable)
> + to->unreadable = 1;
> +
[ ... ]
--
This is an AI-generated review.
next prev parent reply other threads:[~2026-08-18 10:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 19:13 [PATCH net v4 1/2] net: core: propagate unreadable flag in skb_zerocopy Mina Almasry
2026-08-14 19:13 ` [PATCH net v4 2/2] net: tcp: block mixing readable and unreadable frags Mina Almasry
2026-08-18 10:26 ` Paolo Abeni
2026-08-18 18:37 ` Mina Almasry
2026-08-18 10:25 ` Paolo Abeni [this message]
2026-08-18 18:36 ` [PATCH net v4 1/2] net: core: propagate unreadable flag in skb_zerocopy Mina Almasry
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=20260818102557.132214-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=aconole@redhat.com \
--cc=almasrymina@google.com \
--cc=asml.silence@gmail.com \
--cc=bobbyeshleman@gmail.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=echaudro@redhat.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kaiyuanz@google.com \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=willemb@google.com \
/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