🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26311

[PATCH net] ipv4: do not trust ICMP-locked PMTU while forwarding

#26311
From: James Sawyer via B4 Relay
Date: Thu, 03 Dec 2026 11:59
114 lines
15560 bytes
From: James Sawyer <james@jamessawyer.co.uk>

Commit f87c10a8aa1e ("ipv4: introduce ip_dst_mtu_maybe_forward and
protect forwarding path against pmtu spoofing") made the forwarding
path ignore path MTUs learned from ICMP, because they can be forged,
and only honour an MTU the administrator locked on the route.

Commit d52e5a7e7ca4 ("ipv4: lock mtu in fnhe when received PMTU <
net.ipv4.route.min_pmtu") made ICMP-learned values below min_pmtu
"locked" as well, so the host stops setting DF on its own packets, and
switched ip_dst_mtu_maybe_forward() to ip_mtu_locked(). As a result the
only learned PMTU that forwarding still trusts is a value below
min_pmtu, which is the value an off-path attacker would pick.

One ICMP fragmentation-needed message sent to a router, quoting a UDP
packet from the router to a destination D with an MTU below 552, makes
the router clamp to 552 every DF packet it forwards to D, for 600 s,
renewable. Hosts behind the router get frag-needed (mtu = 552) from
their gateway, and DF traffic larger than that (for example QUIC, which
needs 1200 bytes) to D fails; their TCP MSS to D drops to 500. No socket
has to match the quoted packet: a quoted ICMP echo reply reaches
ipv4_update_pmtu() through icmp_err(), and a quoted UDP packet does so
through udp_err_update_exception().

While forwarding, trust only the administrative lock again, in both
places the helper tests it; the 576-byte clamp for gateway routes
further down must not apply to an ICMP-induced lock either. Local
traffic keeps the 2018 behaviour (no DF on its own packets).

Reproduced on 7.0.0-43-generic (Ubuntu 26.04) with network namespaces:
a NAT gateway with two inside hosts, an attacker that can reach only
the gateway's public address and D, and UDP 1200-byte payloads with
IP_PMTUDISC_DO and IP_PMTUDISC_PROBE from both inside hosts: 0 of 3
delivered after one forged message with MTU 551 (3 runs); delivered
after a forged MTU of 1000 (unlocked) and with net.ipv4.route.min_pmtu=68
(the same value stored unlocked). Quoting an echo reply instead of UDP
gave the same result. The same worked from an inside host against a
gateway whose input policy trusts its LAN. An independent reproduction
on a second VM with separately written scripts matched every case.

Tested on v7.4-rc1 in QEMU with the same setup: unpatched, one forged
MTU 551 left 0 of 3 DF datagrams delivered from each inside host; with
this patch the exception is still stored ("mtu lock 552") but forwarded
traffic is unaffected (3 of 3, ping -M do 1400 passes), and the
router's own output still honours the stored PMTU. Built with W=1
(ip_forward.o, ip_output.o) without warnings.

The netfilter flowtable uses the same helper and is covered by this
change. IPVS (dst_mtu() in ip_vs_xmit.c) and ipmr have their own MTU
logic and are not changed here. A reproducer is available on request.

This issue was found and the fix written with AI assistance.

Fixes: d52e5a7e7ca4 ("ipv4: lock mtu in fnhe when received PMTU < net.ipv4.route.min_pmtu")
Signed-off-by: James Sawyer <james@jamessawyer.co.uk>
---
Notes for reviewers (not for the commit):
- Found and fixed with AI assistance. All measurements were run by me in a
  lab on 7.0.0-43-generic (Ubuntu 26.04) in network namespaces; the same
  code is in 7.4-rc1. A reproducer (namespace rig + forged ICMP) is
  available privately on request and is not being published.
- Related, sent separately: an ip_tunnel patch for IPv6 payload when the
  tunnel MTU drops below IPV6_MIN_MTU.
- Not covered here: IPVS (ip_vs_xmit.c uses dst_mtu()) and ipmr have their
  own MTU logic; I have not tested them.
---
 include/net/ip.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/net/ip.h b/include/net/ip.h
index 0acc4ba5e5b3..86244604fee6 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -478,13 +478,21 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
 	const struct net_device *dev;
 	unsigned int mtu, res;
 	struct net *net;
+	bool locked;
+
+	/* While forwarding, trust only an administratively locked route
+	 * MTU. rt_mtu_locked is also set when an ICMP-learned PMTU is below
+	 * min_pmtu, and such ICMP messages can be forged off-path.
+	 */
+	locked = forwarding ? dst_metric_locked(dst, RTAX_MTU) :
+			      ip_mtu_locked(dst);
 
 	rcu_read_lock();
 
 	dev = dst_dev_rcu(dst);
 	net = dev_net_rcu(dev);
 	if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) ||
-	    ip_mtu_locked(dst) ||
+	    locked ||
 	    !forwarding) {
 		mtu = rt->rt_pmtu;
 		if (mtu && time_before(jiffies, READ_ONCE(rt->dst.expires)))
@@ -498,7 +506,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
 
 	mtu = READ_ONCE(dev->mtu);
 
-	if (unlikely(ip_mtu_locked(dst))) {
+	if (unlikely(locked)) {
 		if (rt->rt_uses_gateway && mtu > 576)
 			mtu = 576;
 	}

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261203-ipv4-fwd-icmp-locked-pmtu-0c179dc82b44

Best regards,
--  
James Sawyer <james@jamessawyer.co.uk>
Technical Details
Message-ID: <20261203-ipv4-fwd-icmp-locked-pmtu-v1-1-e5f48573bbf0@jamessawyer.co.uk>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376533-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376533-linux-kernel-netdev=dewy.ru
From: devnull+james.jamessawyer.co.uk@kernel.org (James Sawyer via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] ipv4: do not trust ICMP-locked PMTU while forwarding
Date: Thu, 03 Dec 2026 11:59:01 +0000
Organization: Usenet Network
Message-ID: <20261203-ipv4-fwd-icmp-locked-pmtu-v1-1-e5f48573bbf0@jamessawyer.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2478196"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:SM5Tm8x3AWMZ61y+QXwR/Zgoyv0= sha256:9Z7OaoAxWQxAFk+btWCjls+/xD1ktoY898UkS7nDlfg=
	sha1:AzcRntA3fbTnJzDZAQikyUlgfGU= sha256:rbQiB8RgF77S1jBZUXhljZNn5wmNfAMVvqFAX+EBnoI=
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 771D51178FD; Thu,  3 Dec 2026 14:59:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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] 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 suuq0_VWL1rT;
	Thu,  3 Dec 2026 14:59: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-376533-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 8106E1178F2; Thu,  3 Dec 2026 14:59: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 B086626EE5; Thu,  3 Dec 2026 11:59:12 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796299152;
	b=CLJhWtC4BTWW2Kwxcp7O/1d1ew39rJH4hPPPMm8nZKTGTTkM5EIh/LMgUNMq5JJUA3N4
	 RfDgnySqKrdMSPdjIIMeZokklhpSKB1Hcc/B4Y4duAoHOeax83VITBXEsfPlBW5G3PfK5
	 2z+2zjj0rrQzTZsMq4H1i0BcN97lbLESVGYFbi9o4Q/uCqOb9KEy6hnHLgnNk//E/VieZ
	 teq/6g1frETGjdbJaeiRA3P4YUd3Is68kQOGxc8p4EK77xvAvWIbzWAKKaVPQBId9vOlr
	 yVz4/oMVXDGTdA1xaefIDWEhunB6yE7iDl9qD7WVonoXQW/4ZY5PF5Ybco/ayge7MjA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796299152;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=1++Ws/PxXbbckP5+gsxzKWmmSFhHnSmWOONlR64AFpA=;
	b=XP6/a5AvqDQzTcVgmi22x3Jnbila3LULkoPDLXVa53R8ueF5zmksdsL1N/eoe0MFMZV1
	 g/ViqD2yfkuqhE6YWngpcLlj49xGW/hnTNiL7CnVhGXhFeHdXoHUQ5l4e6qplxQ+9st3s
	 ADt4CoOCuMVpv7zdh7wFKKTQYpOhA6/54qcFZ4h8FUpVhby5SV/NMS38Y5U2oqw27iNN1
	 YFJYWiz5OzxgMifjADJbsr1hd1PtvaJbm0aFegal6BEHZ/T9nNF80dL4RcRn+pOO528bR
	 PAg5wTk6UoedaRSdUd8eADzdwm1gNY017VLHh6kkJJn1OEodtCtC5OEVXfTYm2W1ssw==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NyMTyI8V;
	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 285ED606A322;
	Thu,  3 Dec 2026 11:59:12 +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=NyMTyI8V
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796299146;
	b=ivaBLLBEcqfF4lxG2r7t5YTmzvV7xYMP93oh/PcquzHD3cCzDtBvxPVbcdYrm1hx9kql
	 CBjPpGWg7bv2boBgMD7P6HfPnMMt0RhG8EraI7FWYA5YMRr7Fzn6DW1D7/YjpshUn4X01
	 R5rBeRy02iq/MhhHMaaypq5DY0uQTRZSjuGPMu9ga2bH/cvBR2DdkY8Lf42Fok5Kasg57
	 p2hAuoaWJiMdYP2PTXzII688ZNodtLjVbljlcQ7XoAv+zH6K/gOxKhWvHyCp57TjMLb8K
	 YjC2/8wnxG4kCSeW5b0ln+B/dolMHBzSFAXzqkh2CCKpcQjR6WGj6WY5x/xG2ZQWxHQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796299146;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=1++Ws/PxXbbckP5+gsxzKWmmSFhHnSmWOONlR64AFpA=;
	b=C/K8ZMg2se3nM3OUY70myC2dm/7Slip3/IkFsTVnoG0Tnov319VIJa70PeA0GruCWokd
	 IM3eNUDLfLKXc/54fjFQxS+6UF04I64thTdlPOyvlCOXlpokX76wPkRxnit1SWMeQmKO8
	 mOAzmygb/tOfv2CfIE9K8YmjHh/A1Pr1Mj6yYaOyAolnYxO9QmtTIdmgazg7Q8Py1cZ/V
	 0t9sr2NPtc3uwVccNVzBpLoSNUMyTu5adcFaSi/GHStklQYAkDT2nfvIhtp+WrhTQpWJA
	 POCVGDlTctxTswa52GnXwjuhWrQNJzvqK81dRUXgS5cIeYxdhIWPI4T+VPWu7hj27RQ==
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=NyMTyI8V;
	arc=pass header.oldest-pass=0 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 474F6606A684;
	Thu,  3 Dec 2026 11:59:06 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1796299146;
	b=F/8msdGlin9gFvWw+SsKBXUI2CyiaKZnSm0M7JDe1lpQfzRYt9hiJS2RazrXAWqSPPK5
	 5U3q5Qfj99ELGFa+Ii2GVhRzfC4fHpqAcov63342V5+4J/vNMOT4Z5NxOumIrgT/wYtTt
	 YcQUTJ41rt9HnkwQAAZuoJ2/uzlEMKM76nI87ktZ/adU/6UXjyktkqv8OTJ9IqFb7NvZr
	 1wTSV/1WntD8P1cFKB/NjmYqZJrjmRTXRKg9PiCQEc1Fdqx1s7EV2lSjFrWNJZlfFJ1+u
	 BLMFgXjpoYT4gzABgQqgi1GqkVGqiKJG4kyo+175l45vdBEClpCHHoQrlAXfLnu0oOw==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1796299146;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=1++Ws/PxXbbckP5+gsxzKWmmSFhHnSmWOONlR64AFpA=;
	b=d0JFeUfqtYNC30XmSyZMPCOAa7eJXW0SzKRCvOFaO9YnCFeyTD9B+zx6v6cAj5yyQD6S
	 i3q9EtDrvqfh5KGTjnQ084j4pDUtBbmAVtt3uJkkOZiTELl3+wpYC5iQdmdW85f9xgq/i
	 D0TtZv/k21g1LgXDwhpB/npUsKF9Txq4Rn5+co+M4MGvYLbQNPbrp/DxnokBJaztyKwIB
	 dywOoja0dM7EvTrflY4beacvT/28GVln0o11k8+LL/O0M+GsotkZbTNC+ig4WhSBaifj2
	 kPdr+LPS7yB7ddPA+ZTRITI9iNGjz1s4SOruD1BM2zNsA1uTq4ng+fHT6YMQCAniVng==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.kernel.org (Postfix) with ESMTPS id 9EA6A1F000C1;
	Thu,  3 Dec 2026 11:59:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796299146;
	bh=1++Ws/PxXbbckP5+gsxzKWmmSFhHnSmWOONlR64AFpA=;
	h=From:Date:Subject:To:Cc:Reply-To;
	b=NyMTyI8V62tOwHzbVYKaPTbnnHrm2177D5h2sodCSsecJ8Yz1zmjB1CSFqUrYRBm3
	 ZkryzpPIGqDKQ3SegHKmsBjUt2m+k6mqFnk3H4HDtkJ9cMoy+L7Ke/e64HymYNjqjk
	 +1Yv4cXb6q3vaD35L8SHT/Ss6+ZuPJhUN5jDAhyW8f9jdjyupY2pimgfTwV0dMEx2J
	 Q7ujCOfZ3BdV5w1+VvXu51zJ3z3mcv9pABk926IQQjidPH4nEpzkgYYLCIePmXFTWQ
	 GoGXqwh/VPQCKb8RUJ9FYszx/14qK33AoaQLxisOpsjaV05Lnw5fBayC6k0wfbeR9W
	 +j3ykOQnrx9ag==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id EF9884F6CB;
	Thu,  3 Dec 2026 11:59:03 +0000 (UTC)
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
X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMQQ6CMBAAv0L27CZtbUT9iuEg2wVXpTRtQRPC3
 61wnElmFkgchRNcqwUiz5Jk9AX0oQJ63H3PKK4wGGVO2qgjSpgtdh+HQkPA90gvdhiGPKEiXV8
 cnU1rLZQ+RO7ku71v4DlDs8s0tU+m/L/Cuv4ADnayhYIAAAA=
X-Change-ID: 20261203-ipv4-fwd-icmp-locked-pmtu-0c179dc82b44
X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 
 James Sawyer <james@jamessawyer.co.uk>
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=ed25519-sha256; t=1796299143; l=5122;
 i=james@jamessawyer.co.uk; s=20261203; h=from:subject:message-id;
 bh=9kMa3MDfyXKN+QJN9IT9wVRH5pNztEYdFNYyxYz0LRE=;
 b=kUscLNtLZYXgWoRqdb9ZVFNqM/zBEqSLKk12fUNZkHTuQHJUjw5i8rWdzeUTJI+qezrg+69Pq
 /D8mj6ymIKYA2Xk8xBTi/ne2xxmqbXpxNAd4GyAW9JwZHRay20+IMUq
X-Developer-Key: i=james@jamessawyer.co.uk; a=ed25519;
 pk=97d0xHacZOmlJXs5Pj8Vv8mVWW2CBNhqBLMVT3VQjis=
X-Endpoint-Received: by B4 Relay for james@jamessawyer.co.uk/20261203 with
 auth_id=1733
X-Original-From: James Sawyer <james@jamessawyer.co.uk>
X-Reply-To: james@jamessawyer.co.uk