Thread (28 messages) flat view 28 messages, 5 authors, 2026-01-13

Re: [PATCH net-next 14/17] udp: Validate UDP length in udp_gro_receive

From: Paolo Abeni <pabeni@redhat.com>
Date: 2025-09-25 14:10:12

On 9/23/25 3:47 PM, Maxim Mikityanskiy wrote:
quoted hunk ↗ jump to hunk
From: Maxim Mikityanskiy <redacted>

From: Maxim Mikityanskiy <redacted>

In the previous commit we started using uh->len = 0 as a marker of a GRO
packet bigger than 65536 bytes. To prevent abuse by maliciously crafted
packets, check the length in the UDP header in udp_gro_receive. Note
that a similar check is present in udp_gro_receive_segment, but not in
the UDP socket gro_receive flow.

Signed-off-by: Maxim Mikityanskiy <redacted>
---
 net/ipv4/udp_offload.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 1e7ed7718d7b..fd86f76fda2c 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -788,6 +788,7 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
 	struct sk_buff *p;
 	struct udphdr *uh2;
 	unsigned int off = skb_gro_offset(skb);
+	unsigned int ulen;
 	int flush = 1;
 
 	/* We can do L4 aggregation only if the packet can't land in a tunnel
@@ -820,6 +821,10 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
 	     !NAPI_GRO_CB(skb)->csum_valid))
 		goto out;
 
+	ulen = ntohs(uh->len);
+	if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb))
+		goto out;
Possibly consolidate both checks in single, earlier one?

/P
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help