Netdev List
 help / color / mirror / Atom feed
* [PATCH net v1 1/2] net: core: check skb_frags_readable before uncloning in skb_copy_ubufs
@ 2026-08-23 18:36 Mina Almasry
  2026-08-23 18:36 ` [PATCH net v1 2/2] net: core: fix head-page leak in skb_zerocopy Mina Almasry
  2026-08-25  9:50 ` [PATCH net v1 1/2] net: core: check skb_frags_readable before uncloning in skb_copy_ubufs patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Mina Almasry @ 2026-08-23 18:36 UTC (permalink / raw)
  To: Jakub Kicinski, Kaiyuan Zhang, Willem de Bruijn, Mina Almasry,
	Eric Dumazet, Zoltan Kiss, David S. Miller, netdev, linux-kernel
  Cc: Paolo Abeni, Simon Horman, Jason Xing

skb_copy_ubufs drops clones and modifies the SKB via pskb_expand_head()
before checking for !skb_frags_readable(skb). This alters the SKB
geometry prior to throwing an -EFAULT on an invalid SKB. Check
readability first.

Fixes: 65249feb6b3d ("net: add support for skbs with unreadable frags")

Signed-off-by: Mina Almasry <almasrymina@google.com>
---
Note to sashiko: if you find pre-existing issues, mark them clearly as pre-existing.
---
 net/core/skbuff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d4382b68d56e0..201c9ec1519c7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2001,12 +2001,12 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
 	int i, order, psize, new_frags;
 	u32 d_off;
 
-	if (skb_shared(skb) || skb_unclone(skb, gfp_mask))
-		return -EINVAL;
-
 	if (!skb_frags_readable(skb))
 		return -EFAULT;
 
+	if (skb_shared(skb) || skb_unclone(skb, gfp_mask))
+		return -EINVAL;
+
 	if (!num_frags)
 		goto release;
 

base-commit: 7cbfb180945ce529608e4d4e24a6d483699fab1e
-- 
2.55.0.766.g2966f0265a-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-25  9:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-23 18:36 [PATCH net v1 1/2] net: core: check skb_frags_readable before uncloning in skb_copy_ubufs Mina Almasry
2026-08-23 18:36 ` [PATCH net v1 2/2] net: core: fix head-page leak in skb_zerocopy Mina Almasry
2026-08-25  9:25   ` Paolo Abeni
2026-08-25  9:50 ` [PATCH net v1 1/2] net: core: check skb_frags_readable before uncloning in skb_copy_ubufs patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox