From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 5C0EC3D170E for ; Tue, 2 Jun 2026 09:41:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780393263; cv=none; b=qKyIJayNAmvb4KiHttnlzpYnYD1hNRf0B+/SxBMJZHAq3s6W5LJZOWm5gBsOtrPFr0V6fUOKxzsxORJD5vtOfRTBWQGg+eAvtbtX8by84jjNnWONyQodSrKvTMLqEDUPieA7/+cgll1Y9Du3yXIGnYIZrsKHi53HrP4/0HXkW10= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780393263; c=relaxed/simple; bh=c1uI3/hJh4++FyVIgYxPClG1QwzJQ/KCKW2GXPfYBxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BVItJdub8wAiGuESlZ4S7t6iu5RWIgQ6IOkYRI7YO5PfEnaXL0YTMgiQS5HH9E4JxRjRm3euIU4Xnha+nr1iwa5cI8uDuwI6KyP26Ahsrh4uNdUE353KRoj4QeHdeFWiROTuqb6fEXlI8FvQvss+42UgrKph9tMy2n4QwH9M3uU= 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=cuw2ozGe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QSdqY9Ih; arc=none smtp.client-ip=202.12.124.152 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="cuw2ozGe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QSdqY9Ih" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 594847A00FE; Tue, 2 Jun 2026 05:41:01 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 02 Jun 2026 05:41:01 -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=fm1; t=1780393261; x= 1780479661; bh=2rF5Na5rgiBkDiR351mPeaPE+SomprcW8q+BWbNvlX8=; b=c uw2ozGe/8DDn4xTOgFRtqOktpGmo4T4R+GDaNTzo0uK2v5AHdjDnwKkPxaLMaf19 eipOw70CEGyFOzRunNZhyq826yqzu1hclA2NciECgrHUZ6er/O/VAgOxCKMvkbYi HqR2PQaTM/pntDb0qf06UTZeiJhFYJ7f2phyVpp5ADdJHQG70QYKy+ODQ8hchlfk iI11dUbhIJWax5v0OABNxJtMC/AjYkM2Vd1hyDNR2DlIN0LKcDbI6UvnHRRlWLpe DLFce53+qEFWP7dpf5am+W+iZFpuBEd+ZtRERm1pkWf7Zk6DNT45l5StupVqPmKZ NQb7JNpwtT/YtWB4vVZNQ== 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=fm1; t=1780393261; x=1780479661; bh=2 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U5OHYfQe9bZ+agsnfskNJHAGo1aI+BrZX6NQ X-ME-Proxy: Feedback-ID: i559e4809:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Jun 2026 05:41:00 -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 v6 07/11] udp: Validate UDP length in udp_gro_receive Date: Tue, 2 Jun 2026 11:39:27 +0200 Message-ID: <20260602093931.516281-8-alice.kernel@fastmail.im> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260602093931.516281-1-alice.kernel@fastmail.im> References: <20260602093931.516281-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 f7da760f046f..d5d1dc8d0bb9 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -707,12 +707,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)); @@ -782,8 +778,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