[PATCH net] fou: unclone skb before changing the outer header on receive

From: Haishuang Yan

Date: Thu Dec 03 2026 - 05:03:49 EST


fou_recv_pull() and gue_udp_recv() shrink the outer IPv4 tot_len or IPv6
payload_len in place. If the skb is a clone (e.g. AF_PACKET or tc mirred
holds a copy), that copy sees a wrong outer length.

Call skb_unclone() first, as xfrm{4,6}_udp_encap_rcv() do, and reload
guehdr afterwards in gue_udp_recv().

Found by code review. Tested in a KVM guest with FOU and GUE over IPv4
and IPv6 while an AF_PACKET socket holds the received frames: the outer
length it reads is no longer modified.

Fixes: 23461551c006 ("fou: Support for foo-over-udp RX path")
Fixes: 37dd0247797b ("gue: Receive side for Generic UDP Encapsulation")
Signed-off-by: Haishuang Yan <yanhaishuang@xxxxxxxxxxxxxxxxxxxx>
---
The issue was found with the help of an AI coding assistant.

Zero length fields (BIG TCP, jumbograms) still wrap in the subtraction.
Nothing reads the outer length afterwards, so I left that for a separate
change.

net/ipv4/fou_core.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c
index bff4dc488de..19d8714aac3 100644
--- a/net/ipv4/fou_core.c
+++ b/net/ipv4/fou_core.c
@@ -55,6 +55,9 @@ static inline struct fou *fou_from_sock(struct sock *sk)

static int fou_recv_pull(struct sk_buff *skb, struct fou *fou, size_t len)
{
+ if (skb_unclone(skb, GFP_ATOMIC))
+ return -ENOMEM;
+
/* Remove 'len' bytes from the packet (UDP header and
* FOU header if present).
*/
@@ -177,6 +180,12 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
if (validate_gue_flags(guehdr, optlen))
goto drop;

+ if (skb_unclone(skb, GFP_ATOMIC))
+ goto drop;
+
+ /* guehdr may change after unclone */
+ guehdr = (struct guehdr *)&udp_hdr(skb)[1];
+
hdrlen = sizeof(struct guehdr) + optlen;

if (fou->family == AF_INET)

base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
--
2.43.0