๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21227

Re: [PATCH net] udp: gro: do not match tunnel-processed and plain packets

#21227
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 18:40
158 lines
13784 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The Fixes: tag covers only the out-of-bounds read, not the
  older mis-merge bug.
- [Low] The new comment and the commit message both say encap_mark is set
  for any tunnel-processed packet; FOU and GUE clear it.

--

udp: gro: do not match tunnel-processed and plain packets

With this patch, udp_gro_receive_segment() skips held packets whose
NAPI_GRO_CB()->encap_mark differs from the incoming skb. A plain UDP
datagram is then no longer compared against, or merged into, a held
packet that went through a vxlan/geneve GRO handler. For such a packet
udp_hdr(p) points at the inner L4 header.

> When the bytes read happen to match, the UDP payload is merged into the
> tunnelled TCP aggregate. With rx-gro-list and forwarding the datagram
> is then segmented and sent out with the inner flow's addresses, without
> having been seen by the forward or egress netfilter hooks.

[ ... ]

> Fixes: 4b0ebbca3e16 ("net: gro: move L3 flush checks to tcp_gro_receive and udp_gro_receive_segment")

[Severity: Medium]
Does this Fixes: tag cover the whole bug?

4b0ebbca3e16 added the gro_receive_network_flush() call, and that call is
where the out-of-bounds read comes from. The port comparison against a
tunnel-processed held packet looks older:

net/ipv4/udp_offload.c:udp_gro_receive_segment() {
    ...
		uh2 = udp_hdr(p);

		/* Match ports only, as csum is always non zero */
		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source)) {
    ...
}

Blame traces these lines to e20cf8d3f1f7 ("udp: implement GRO for plain
UDP sockets.").

udp_hdr(p) points at the inner L4 header because the inner
inet_gro_receive() resets p's transport header:

net/ipv4/af_inet.c:inet_gro_receive() {
    ...
	skb_set_transport_header(skb, skb_gro_offset(skb));
    ...
}

Before 4b0ebbca3e16, flush came from NAPI_GRO_CB(p)->flush/flush_id.
inet_gro_receive() computed these by comparing the outer IP headers (ttl,
tos, DF, id) at the same offset in both skbs. The remote sender controls
all of those fields. Before 5babae777c61 there was no flush check at all.

On those kernels, can a plain UDP datagram whose ports equal the inner TCP
ports of a held vxlan packet reach skb_gro_receive() through a UDP_GRO
socket or rx-udp-gro-forwarding, without reading any out-of-bounds bytes?

If so, "when the bytes read happen to match" is only true after
4b0ebbca3e16. Backporters who follow the current tag would skip 6.6, 6.1,
5.15 and 5.10, and those trees still have the cross-flow merge. The
rx-gro-list forwarding variant needs TCP fraglist GRO, so it does not apply
to those older trees.

encap_mark has existed since 2016, so the check should backport easily.
Would it make sense to add:

Fixes: e20cf8d3f1f7 ("udp: implement GRO for plain UDP sockets.")

and keep the current tag for the out-of-bounds read? The message could
then say that on older kernels the mis-merge does not need the
out-of-bounds read.

> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index b77ae2f00c626..160b60005a1b6 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c
> @@ -723,6 +723,17 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
>  		if (!NAPI_GRO_CB(p)->same_flow)
>  			continue;
>  
> +		/* encap_mark is set once a packet has been through a tunnel
> +		 * GRO handler (vxlan, geneve, ...). For such a packet
> +		 * udp_hdr() points at the inner L4 header and its network
> +		 * offsets describe the inner packet, so it must not be
> +		 * compared with a packet that has not been through one.
> +		 */
> +		if (NAPI_GRO_CB(p)->encap_mark != NAPI_GRO_CB(skb)->encap_mark) {

[Severity: Low]
Is this comment accurate for FOU and GUE? The commit message makes the same
claim:

  NAPI_GRO_CB()->encap_mark records whether a packet has been through a
  tunnel GRO handler.

fou_gro_receive() and gue_gro_receive() in net/ipv4/fou_core.c both clear
the mark after tunnel processing:

net/ipv4/fou_core.c:gue_gro_receive() {
    ...
	NAPI_GRO_CB(skb)->encap_mark = 0;

	/* Flag this frame as already having an outer encap header */
	NAPI_GRO_CB(skb)->is_fou = 1;

	ops = fou_gro_ops(sk, proto);
    ...
}

For GUE version 0, the sender chooses proto through guehdr->proto_ctype.
With IPPROTO_UDP, the packet reaches
udp4_gro_receive()->udp_gro_receive_segment() with encap_mark == 0. No
inner IP layer runs, so the transport header stays on the outer UDP
header.

Two such GUE-direct-UDP packets have equal encap_mark, but the headers
being compared are from different layers. uh from udp_gro_udphdr(skb) is
the inner UDP header. udp_hdr(p) is the outer GUE UDP header.

If the sender sets the inner ports equal to the GUE port, can the packet
match any held GUE-direct-UDP aggregate of the same outer flow, whatever
its inner ports are?

This path has no out-of-bounds read, because the offset difference is only
the outer IP header length. The cross-inner-flow merge also predates this
patch. Still, the invariant stated in the new comment and in the commit
message does not hold for FOU/GUE.

Could the comment say that encap_mark tracks whether an inner network layer
was processed, rather than tunnel processing in general? Alternatively,
could the check also compare is_fou?

> +			NAPI_GRO_CB(p)->same_flow = 0;
> +			continue;
> +		}
> +
>  		uh2 = udp_hdr(p);
>  
>  		/* Match ports only, as csum is always non zero */

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122183951.73210-1-aviralyash27%40gmail.com
Technical Details
Message-ID: <179545921450.3135.6404804724515356262@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369676-linux-kernel-netdev=dewy.ru
References: <20261122183951.73210-1-aviralyash27@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369676-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] udp: gro: do not match tunnel-processed and plain packets
Date: Mon, 23 Nov 2026 18:40:14 +0000
Organization: Usenet Network
Message-ID: <179545921450.3135.6404804724515356262@kernel.org>
References: <20261122183951.73210-1-aviralyash27@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3955490"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HO7xCR/o0SYGxnb1DboWnFV3wA0= sha256:PnUCf8vsKJug+S7d/SCiDgxFCYTKNxuqBA6ExMisVPg=
	sha1:6re/en6SsTq4AvysnNwVy1kzwaM= sha256:VTUVQG00eBGPCOLWEn0aN/NVc44UQN5Qh7Igl134XZM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 05D18125DC3; Mon, 23 Nov 2026 21:40:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id poFO8uYsqnmt;
	Mon, 23 Nov 2026 21:40:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369676-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 381AF125DC1; Mon, 23 Nov 2026 21:40:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 22E9034FCC; Mon, 23 Nov 2026 18:40:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795459217;
	b=SHJcCMK59M46KSdjHY6idT8mnl4tSNoVreFiJAPhdYAtJ0qdk9/kFJOaPPVOvviFVJut
	 IOBpQ76nN3BkOCk1mv1Lr1PXWFYbtmkSR3DJlXRsAus+bWZ4BB5NtrvCXN2fOgJiK0rVF
	 SSFJAKR1Kb+wsJS2M7KjlW6JFpavlkkhXVgv4KEssveyeYzmdUwaF9fBB/epNY0pnsiOy
	 t8vvWMeRnLV0whrB2hn9zE31VX5/Nz7RFqjQmSu0mBeRBZkYdeAN/M5SQXnzsZfMLgrwI
	 7tVdWA7iYUskrC3bR+ifr5xGPaWcMFchIiQmOQcZlJEFX6H1svK1yXaXzg/RlUIPbeg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795459217;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=97n/AA44OWEFHAxhIbrtHJJ0Jb7k6ivcJGdUSEplDWU=;
	b=DpF/JRAKVKNr5N9Ap03+eCT/1yRgyZFWom/ATmkY79Gus8cCLqZj+q6EGEsRUo4eeSlA
	 enqBsibXhFw5RR8FAlMvzLQpybbRDPNbRDTRybXNjo4AvKdGi+lWguew51tn+mBGiSX/5
	 /zvTVx6j5NXrTzgK93n/ZtNvjGPlnSBDjYCijvpim6gwI/+jMvKq7V4cerWrbTeP2mf6R
	 1kK5FcvZoAlvESDplw+hhOnFrhSWofRFQP/ssYLKunuPz9cZyFc3FkzIyWr/2AJZ4M6fA
	 /10ZgROEAQ0cs1urfX9xY0PzowE3juAezazggtUfGC5LSv8YcjcasMufHIiLXidtVZA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=A9jy3mg7;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id E00EE606A32C;
	Mon, 23 Nov 2026 18:40:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=A9jy3mg7
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795459216;
	b=HOSVe8LIAbK9nai9d/DypXz5Rj4DWl48u3XgTDHgUImsvumVNgwt0RM9PsBHn9dr3368
	 8v7vWOnuc0zdOCgPzDUdis24zPUh1MIjZZwB9yhUiPkzaZTIDZ8UYBGIag/jKs/1WyhCL
	 iY4vutGOs9xmg9gCExwQFAcHQ/InVQ/saHV9vLoMfM3w2VUUQ5zQKjIiv4+UNjINwi6ve
	 SVGSkoLEsrTtBU/hzMYVqm8sITlbiv6FXWTwTCvtpQTQomMqIxCVEDX4b+IheESDfWxHC
	 7q7NmdjktVYLX2FMcnu/Dr7af3B5IdiTuEN5zakLUEanmmKdGIx08Md6tOVh27PBA2Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795459216;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=97n/AA44OWEFHAxhIbrtHJJ0Jb7k6ivcJGdUSEplDWU=;
	b=MQJI0h0MNj0nrDqEB2mhn2bGQ5YMj9R1vJeB2PFzx5EImNBHbMyGeIZvH041F124Ef37
	 RN9NYIMSDd53juBGjkH36YsCJSnIhF6cV5oIMqSknrkaN3NRXvji44xflsNL4dAj6q7EY
	 OA9zsRDCHA2ofXW+gRQfMp8g5u0ponN14l7CUWJeUDA0k2G2sVvCDkD2XKQrVEocZfOCM
	 dMeaUCI332VfIHErLgSAalyriKNK4uHrThRKELtE4yU4Sva/6yx3RvpZJPpjCeuyWNYOI
	 lROYqNesQjjf1Tbn/q/GofbPrAELDV2NmxctNdVGa14m2OW03YgH+5xG4uzrCukSK7A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=A9jy3mg7;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 089D5606A31A
	for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 18:40:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E96A11F000CF;
	Mon, 23 Nov 2026 18:40:14 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795459215;
	bh=97n/AA44OWEFHAxhIbrtHJJ0Jb7k6ivcJGdUSEplDWU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=A9jy3mg70bfhipdHr1f6Gjr3jKKYux/gZDGREMVky1I3aZgo+6zADncbVQYP3Xv01
	 rFm0BC3xDxiK/g4NmU7HLkznPPf9xpD1QyvETpl+DNVSVSeBcgrw4Vtk4KhuuNxewa
	 rxFiBKpzAGppzzkYu7lZ7+A71/i1bAc4hpQNMg48PZd2v4YnQVT84WGU9lvFEU93fY
	 70a9TbUc6HeoyqeLRUx950weTrRqiWAIgqjRh2ypGR9/4pQzsQ6E+TedcrEQ5ial2a
	 idTnnyd/fGOTEePVmP1OhkMa2beefjbG7J7eUNafaSysyvjavhCImYlirxwtjxNLJv
	 OWcUJasQaaIUg==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org
X-In-Reply-To: <20261122183951.73210-1-aviralyash27@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list