From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 585823D9678 for ; Tue, 12 May 2026 16:58:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778605101; cv=none; b=ahzIvCkpskdJ3R0DuL7pFM++IhmnVG6z92MfENn0pvhwMwawLNSZ50QHhBULkAS19MZvt8O8FUHhsDsFPVRSAEFF+ufbqJfR1TIEb8Bv7AKUwsXCdlUs4w71OFCv74H9Q1PTr8EU0Z/rw+TztxafjqM2ihE/yBgq7nSUW2MDEgU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778605101; c=relaxed/simple; bh=kJb3wCcAjVWh2DEmWg3hZjWXEeaVslT2uSAEk7ZNiCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PZT7QVk4JkwAt6g/icMcObtMcqDrp91ikJvnycvhGI0L33XuDFBdQAnRug60fdhfBCeeGnbUe/x6xKswt6qr/yFmNpukZp2nTL98SodUouM9ANxKhCVeWdzmRgIloSe5GISZBDlF6vG0X+68KfUwTwohqc9AZxi/G8liyFOI5a4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.im; spf=pass smtp.mailfrom=fastmail.im; dkim=pass (2048-bit key) header.d=fastmail.im header.i=@fastmail.im header.b=gYCTM2bU; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fsXP1eKt; arc=none smtp.client-ip=103.168.172.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fastmail.im header.i=@fastmail.im header.b="gYCTM2bU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fsXP1eKt" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 9DBE2EC023F; Tue, 12 May 2026 12:58:19 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Tue, 12 May 2026 12:58:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.im; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1778605099; x= 1778691499; bh=Rao+OQEzV0RiWsArKGBOXmjxJi7aTYahkFiOyHcTPeM=; b=g YCTM2bUkzICRTgndlki3Qfxl1JZvsKIRbDSgy7rt0Sp/ehcipkgOIToCCLG1y33H Jy0LpwfX4z+hMQKVUDhpHg33J3qRMSKRw38Uwn/mlrhtuQu6tDKPtRC8tjn4ktuN CDmlAClVh0VadYeufLZIP8A1isNZz6aP3QRoWZfuU9UpKTLPAkPDtZp9FPXAfrKl QMPrPEdCOJvn8/2VE6b6Vls9Xp2PlsQiup5opka4FEiYoDnWM6lL+aHemkb8oKpe xKwFcikERiALiYgYJIHGD5kD6WH0ffooO11Ymlx9sYCYItG1fLYoa7W+hDY5HPko eN/GduyDvhvU1zh8GsT8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1778605099; x=1778691499; bh=R ao+OQEzV0RiWsArKGBOXmjxJi7aTYahkFiOyHcTPeM=; b=fsXP1eKtdHZD++csr +fS3urYmapNU/eogJOxqz5OvVkyuqK54Njy/yJ7FvAmv6coSsm872hYIFvHrWdal /dMtYrWbRDT/CFzNHDIz5yitWje5DsisKerrib9uUop2R/I9j5nnH5aS3rQPoNT5 SViiciqN+TuDdcXTgAT5WkJAPT/8HCO4Q/4dJJbxs2mAu8ULePpoKxrRrpBqC18P kNa9uAvmQgWWjKK73F+gayyZSnLuCEUCI/tNl2je+gPqcBy80uMUn8SEwGgI/Hst oRGX4qcws2Rp5Iy1PTi05ZzR13wWtzJlExO2Zlw9fqT0U6eE++O+RQxMNq6Snbt8 8lUVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduvddvfeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehlihgtvgcu ofhikhhithihrghnshhkrgcuoegrlhhitggvrdhkvghrnhgvlhesfhgrshhtmhgrihhlrd himheqnecuggftrfgrthhtvghrnhepteffleejfedvhfehieejlefgkeeljeevueeggeev tefhgfeuhfduffegkedvtddtnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpe hmrghilhhfrhhomheprghlihgtvgdrkhgvrhhnvghlsehfrghsthhmrghilhdrihhmpdhn sggprhgtphhtthhopedujedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuggrnh hivghlsehiohhgvggrrhgsohigrdhnvghtpdhrtghpthhtohepuggrvhgvmhesuggrvhgv mhhlohhfthdrnhgvthdprhgtphhtthhopegvughumhgriigvthesghhoohhglhgvrdgtoh hmpdhrtghpthhtohepkhhusggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehprggs vghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtoheplhhutghivghnrdigihhnsehgmh grihhlrdgtohhmpdhrtghpthhtohepfihilhhlvghmuggvsghruhhijhhnrdhkvghrnhgv lhesghhmrghilhdrtghomhdprhgtphhtthhopeifihhllhgvmhgssehgohhoghhlvgdrtg homhdprhgtphhtthhopegushgrhhgvrhhnsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i559e4809:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 May 2026 12:58:18 -0400 (EDT) From: Alice Mikityanska To: Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xin Long , Willem de Bruijn , Willem de Bruijn , David Ahern , Nikolay Aleksandrov Cc: Shuah Khan , Stanislav Fomichev , Andrew Lunn , Simon Horman , Florian Westphal , netdev@vger.kernel.org, Alice Mikityanska Subject: [PATCH net-next v4 08/12] udp: Validate UDP length in udp_gro_receive Date: Tue, 12 May 2026 18:56:44 +0200 Message-ID: <20260512165648.386518-9-alice.kernel@fastmail.im> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512165648.386518-1-alice.kernel@fastmail.im> References: <20260512165648.386518-1-alice.kernel@fastmail.im> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Alice Mikityanska 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 was present in udp_gro_receive_segment, but not in the UDP socket gro_receive flow. By adding an early check to udp_gro_receive, the check in udp_gro_receive_segment can be dropped. Signed-off-by: Alice Mikityanska Reviewed-by: Willem de Bruijn --- net/ipv4/udp_offload.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index 23653872ca65..4bb37c8d234f 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -704,12 +704,8 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head, return NULL; } - /* Do not deal with padded or malicious packets, sorry ! */ ulen = udp_get_len_short(uh); - if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb)) { - NAPI_GRO_CB(skb)->flush = 1; - return NULL; - } + /* pull encapsulating udp header */ skb_gro_pull(skb, sizeof(struct udphdr)); @@ -779,8 +775,14 @@ 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; + /* Do not deal with padded or malicious packets, sorry! */ + ulen = udp_get_len_short(uh); + if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb)) + goto out; + /* We can do L4 aggregation only if the packet can't land in a tunnel * otherwise we could corrupt the inner stream. Detecting such packets * cannot be foolproof and the aggregation might still happen in some -- 2.54.0