Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21f1b8a6 authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller
Browse files

udp: fix GRO reception in case of length mismatch



Currently, the UDP GRO code path does bad things on some edge
conditions - Aggregation can happen even on packet with different
lengths.

Fix the above by rewriting the 'complete' condition for GRO
packets. While at it, note explicitly that we allow merging the
first packet per burst below gso_size.

Reported-by: default avatarSean Tong <seantong114@gmail.com>
Fixes: e20cf8d3 ("udp: implement GRO for plain UDP sockets.")
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fbef9478
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -377,13 +377,14 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,

		/* Terminate the flow on len mismatch or if it grow "too much".
		 * Under small packet flood GRO count could elsewhere grow a lot
		 * leading to execessive truesize values
		 * leading to execessive truesize values.
		 * On len mismatch merge the first packet shorter than gso_size,
		 * otherwise complete the GRO packet.
		 */
		if (!skb_gro_receive(p, skb) &&
		if (uh->len > uh2->len || skb_gro_receive(p, skb) ||
		    uh->len != uh2->len ||
		    NAPI_GRO_CB(p)->count >= UDP_GRO_CNT_MAX)
			pp = p;
		else if (uh->len != uh2->len)
			pp = p;

		return pp;
	}