From: Mina Almasry <almasrymina@google.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jakub Kicinski <kuba@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Eric Dumazet <edumazet@kernel.org>,
Mina Almasry <almasrymina@google.com>,
Kaiyuan Zhang <kaiyuanz@google.com>,
io-uring@vger.kernel.org, Stanislav Fomichev <sdf@fomichev.me>,
Paolo Abeni <pabeni@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Simon Horman <horms@kernel.org>,
Pavel Begunkov <asml.silence@gmail.com>,
Jens Axboe <axboe@kernel.dk>,
Stanislav Fomichev <sdf.kernel@gmail.com>,
Bobby Eshleman <bobbyeshleman@meta.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Neal Cardwell <ncardwell@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next v2 1/4] net: fix skb->unreadable propagation in skb_split() and skb_shift()
Date: Mon, 2 Nov 2026 23:18:24 +0000 [thread overview]
Message-ID: <20261102231827.4088254-2-almasrymina@google.com> (raw)
In-Reply-To: <20261102231827.4088254-1-almasrymina@google.com>
skb_split() and skb_shift() do not accurately maintain skb->unreadable
when moving fragments between skbs:
- skb_split_inside_header() moves all fragments out of skb into skb1
(leaving skb with nr_frags == 0 and only host-readable linear memory),
but leaves skb->unreadable set on skb.
- skb_split_no_header() unconditionally copies skb->unreadable to skb1
even if 0 fragments were moved to skb1 (k == 0), and leaves
skb->unreadable set on skb when splitting at skb_headlen(skb) moves
all fragments into skb1 (!skb_shinfo(skb)->nr_frags).
- skb_shift() neither propagates skb->unreadable to target skb when
shifting unreadable fragments into an empty skb, nor clears
skb->unreadable after all fragments are shifted out of skb.
Fix all three cases so skb->unreadable accurately tracks whether the
remaining fragments in each skb are unreadable.
This issue is theoretical and was found by manual code inspection and
LLM review; it was not triggered in production. Verified with the
net_core KUnit test suite; not tested on real hardware.
Fixes: 65249feb6b3d ("net: add support for skbs with unreadable frags")
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
net/core/skbuff.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 48f6764117243..dc761ceb4d204 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4225,6 +4225,7 @@ static inline void skb_split_inside_header(struct sk_buff *skb,
skb_shinfo(skb1)->nr_frags = skb_shinfo(skb)->nr_frags;
skb1->unreadable = skb->unreadable;
+ skb->unreadable = 0;
skb_shinfo(skb)->nr_frags = 0;
skb1->data_len = skb->data_len;
skb1->len += skb1->data_len;
@@ -4273,7 +4274,10 @@ static inline void skb_split_no_header(struct sk_buff *skb,
}
skb_shinfo(skb1)->nr_frags = k;
- skb1->unreadable = skb->unreadable;
+ if (k)
+ skb1->unreadable = skb->unreadable;
+ if (!skb_shinfo(skb)->nr_frags)
+ skb->unreadable = 0;
}
/**
@@ -4447,6 +4451,9 @@ int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
skb->ip_summed = CHECKSUM_PARTIAL;
skb_shinfo(tgt)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
+ tgt->unreadable |= skb->unreadable;
+ if (!skb_shinfo(skb)->nr_frags && !skb_has_frag_list(skb))
+ skb->unreadable = 0;
skb_len_add(skb, -shiftlen);
skb_len_add(tgt, shiftlen);
--
2.56.0.385.gac671c819a-goog
next prev parent reply other threads:[~2026-11-02 23:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 23:18 [PATCH net-next v2 0/4] net: prevent mixing incompatible memory providers in skbs Mina Almasry
2026-11-02 23:18 ` Mina Almasry [this message]
2026-11-02 23:18 ` [PATCH net-next v2 2/4] netmem: store memory provider private pointer directly in struct net_iov Mina Almasry
2026-11-02 23:18 ` [PATCH net-next v2 3/4] net: add skb_frags_can_coalesce() helper Mina Almasry
2026-11-02 23:18 ` [PATCH net-next v2 4/4] net: prevent mixing frags from different memory providers or bindings 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=20261102231827.4088254-2-almasrymina@google.com \
--to=almasrymina@google.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=bobbyeshleman@meta.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=io-uring@vger.kernel.org \
--cc=kaiyuanz@google.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=pabeni@redhat.com \
--cc=sdf.kernel@gmail.com \
--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
all inboxes | Powered by JetHome®