* [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts
@ 2026-11-26 0:31 Tom
2026-11-26 0:32 ` netdev-bot+sinfo
2026-11-26 8:04 ` Ido Schimmel
0 siblings, 2 replies; 4+ messages in thread
From: Tom @ 2026-11-26 0:31 UTC (permalink / raw)
To: netdev
Cc: David Miller, dsahern, eric.dumazet, kuba, willemdebruijn.kernel, LKML
ICMP error messages are unauthenticated and quote an attacker-chosen
inner header. udp_err_update_exception() (and its IPv6 twin
udpv6_err_update_exception()) process ICMP Destination Unreachable
messages with Code 4 (fragmentation needed, RFC 792) and ICMP Redirect
messages before any socket lookup, calling ipv4_update_pmtu() /
ipv4_redirect() with no socket and oif = 0. The resulting change is
stored in a route entry's PMTU, which every user of that route shares;
on a non-forwarding end host with one route to the internet, the
change affects the entire network namespace.
A single forged ICMP Destination Unreachable with Code 4 lets any
remote host pin the victim's PMTU toward an arbitrary destination,
degrading or denying service for flows using that route, depending on
their packet sizes: values below net.ipv4.ip_rt_min_pmtu are clamped
and locked (see __ip_rt_update_pmtu()), so a locked 552-byte PMTU
persists until a route flush and breaks PMTUDISC_DO senders
(EMSGSIZE) and QUIC (RFC 9000 minimum 1200-byte datagrams), among
others. The in-kernel ICMP
rate limit exempts fragmentation-needed errors from its ratemask, so
attacker-controlled entries can be refreshed unthrottled.
TCP drops errors for packets that match no socket (tcp_v4_err(),
net/ipv4/tcp_ipv4.c); UDP should not be more trusting than TCP on end
hosts, where forwarded flows do not exist: an error that matches no
socket would then change no route state at all.
Fix this by only performing socketless PMTU/redirect updates where they
are actually required -- for forwarded traffic on a router
(net.ipv4.ip_forward enabled on IPv4, net.ipv6.conf.all.forwarding on
IPv6). On routers, this path keeps its original preconditions and
residual exposure, which transit traffic legitimately requires. On
end hosts, PMTU updates continue to work for socket-bound
flows through ipv4_sk_update_pmtu() / ip6_sk_update_pmtu(); those
paths are intentionally unchanged -- an error matched to a real socket
updating the route entry for its own path is the accepted PMTUD trust
model (PMTU state is a route property for TCP and UDP alike; the
matched-socket difference is who may trigger the update, not where the
state lives); this patch only removes the evidence-free flow-agnostic
route-wide write. Errors whose quoted inner header matches no
socket, including those from middleboxes that rewrite or mangle the
flow (NATs without ICMP inner-header translation, for example), are
ignored on end hosts; NAT devices that translate ICMP inner payloads
deliver the original tuple, which continues to match. Encapsulated
tunnels keep their own error path
(__udp4_lib_err_encap_no_sk() / __udp6_lib_err_encap_no_sk()).
Reproducer (forged ICMP Destination Unreachable with Code 4, inner
header quotes no real socket):
pre: 1400-byte UDP sendto with IP_PMTUDISC_DO succeeds (local path)
send: ICMP Destination Unreachable, Code 4, next-hop MTU = 1100,
inner IP header src=<local>/dst=<peer>,
inner UDP header (no matching socket)
post: same sendto returns EMSGSIZE; claims below ip_rt_min_pmtu
(default 552) additionally install a locked 552-byte floor that
persists until a route flush; identical result with a packet
source address that does not match the inner header (nothing
correlates them).
Verified on two builds of the same kernel (6.12), differing only by
this change: without it, a forged ICMP Destination Unreachable with
Code 4 quoting a UDP flow with no matching socket installs the route
MTU for MTU = 1100 (unlocked, self-heals via aging) and for MTU = 500
a clamped locked 552-byte floor that persists until a route flush; a
forged packet quoting zeroed inner UDP ports behaves identically. An
error matched to a real connected UDP socket still applies its PMTU to
that socket's path (the unchanged socket-matched PMTUD path,
ipv4_sk_update_pmtu()). With the patch and ip_forward = 0, forged
packets of both shapes are ignored while the socket-matched path is
unchanged; with ip_forward = 1, socketless updates keep working
(router parity). A genuine end-to-end PMTU event, generated by a real
forwarding router with an 800-byte-MTU egress interface against a
PMTUDISC_DO sender, still shrinks the sender's route: the sender gets
EMSGSIZE on the oversized datagram and completes delivery at the
reduced size, with and without the change.
Also gates the Redirect half of the same problem pre-lookup
(udp: ipv4_redirect()/ip6_redirect() were reachable from forged ICMP
Redirects without a socket); generic ICMP redirect dispatch is left
untouched for other transports.
Signed-off-by: Tomas Bortoli <tomasbortoli@gmail.com>
---
net/ipv4/udp.c | 15 +++++++++++-----
net/ipv6/udp.c | 6 ++++++
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 2e5562f353f8..503575f0cf6c 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -913,10 +913,17 @@
static void udp_err_update_exception(struct net *net, struct sk_buff *skb,
int type, int code, u32 info)
{
- if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED)
- ipv4_update_pmtu(skb, net, info, 0, IPPROTO_UDP);
- else if (type == ICMP_REDIRECT)
- ipv4_redirect(skb, net, 0, IPPROTO_UDP);
+ /* ICMP errors are unauthenticated and quote an attacker-chosen
+ * inner header. Socketless PMTU/redirect updates are only
+ * legitimate for forwarded traffic on routers; end hosts do not
+ * act on UDP errors for non-existent flows.
+ */
+ if (IPV4_DEVCONF_ALL_RO(net, FORWARDING)) {
+ if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED)
+ ipv4_update_pmtu(skb, net, info, 0, IPPROTO_UDP);
+ else if (type == ICMP_REDIRECT)
+ ipv4_redirect(skb, net, 0, IPPROTO_UDP);
+ }
}
/*
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index a6886a0432f9..d1cf5ce2b00a 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -694,6 +694,12 @@
static void udpv6_err_update_exception(struct net *net, struct sk_buff *skb,
u8 type, __be32 info)
{
+ /* Same hardening as IPv4: only forwarded traffic on routers may
+ * drive socketless PMTU/redirect updates.
+ */
+ if (!net->ipv6.devconf_all->forwarding)
+ return;
+
if (type == ICMPV6_PKT_TOOBIG)
ip6_update_pmtu(skb, net, info, skb->dev->ifindex, 0,
sock_net_uid(net, NULL));
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts
2026-11-26 0:31 [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts Tom
@ 2026-11-26 0:32 ` netdev-bot+sinfo
2026-11-26 0:33 ` Tom
2026-11-26 8:04 ` Ido Schimmel
1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-26 0:32 UTC (permalink / raw)
To: Tom
Cc: netdev, David Miller, dsahern, eric.dumazet, kuba,
willemdebruijn.kernel, LKML
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts
2026-11-26 0:32 ` netdev-bot+sinfo
@ 2026-11-26 0:33 ` Tom
0 siblings, 0 replies; 4+ messages in thread
From: Tom @ 2026-11-26 0:33 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, David Miller, dsahern, eric.dumazet, kuba,
willemdebruijn.kernel, LKML
manual code inspection + runtime validated
Il giorno gio 26 nov 2026 alle ore 01:32 <netdev-bot+sinfo@kernel.org>
ha scritto:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts
2026-11-26 0:31 [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts Tom
2026-11-26 0:32 ` netdev-bot+sinfo
@ 2026-11-26 8:04 ` Ido Schimmel
1 sibling, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2026-11-26 8:04 UTC (permalink / raw)
To: Tom
Cc: netdev, David Miller, dsahern, eric.dumazet, kuba,
willemdebruijn.kernel, LKML
On Thu, Nov 26, 2026 at 01:31:05AM +0100, Tom wrote:
> ICMP error messages are unauthenticated and quote an attacker-chosen
> inner header. udp_err_update_exception() (and its IPv6 twin
> udpv6_err_update_exception()) process ICMP Destination Unreachable
> messages with Code 4 (fragmentation needed, RFC 792) and ICMP Redirect
> messages before any socket lookup, calling ipv4_update_pmtu() /
> ipv4_redirect() with no socket and oif = 0.
This is intentional. See commit 4c3499f79f8c ("ipv4: udp: Create
exceptions before socket matching") and commit ac76cab50e89 ("ipv6: udp:
Create exceptions before socket matching").
If exceptions are only created when the quoted packet matches a socket,
then an off-path attacker can probe the exception cache to discover the
ephemeral port of a connected UDP socket. This patch reintroduces this
side channel on every host with forwarding disabled and breaks
tools/testing/selftests/net/exception_cache.sh.
> The resulting change is stored in a route entry's PMTU, which every
> user of that route shares; on a non-forwarding end host with one route
> to the internet, the change affects the entire network namespace.
The exception is created for the quoted destination address and only
affects traffic towards it.
[...]
> values below net.ipv4.ip_rt_min_pmtu are clamped and locked (see
> __ip_rt_update_pmtu()), so a locked 552-byte PMTU persists until a
> route flush
No. They expire after net.ipv4.route.mtu_expires like other exceptions.
[...]
> The in-kernel ICMP rate limit exempts fragmentation-needed errors from
> its ratemask, so attacker-controlled entries can be refreshed
> unthrottled.
?
These rate limits are for locally generated ICMP packets, not received
ones.
>
> TCP drops errors for packets that match no socket (tcp_v4_err(),
> net/ipv4/tcp_ipv4.c); UDP should not be more trusting than TCP on end
> hosts, where forwarded flows do not exist: an error that matches no
> socket would then change no route state at all.
The exception cache doesn't care about L4. ICMP errors that quote ICMP
packets can already update the cache with no validation and the
validation is minimal when the inner packet matches an unconnected UDP
socket. This is all explained in the commits I mentioned.
> Fix this by only performing socketless PMTU/redirect updates where they
> are actually required -- for forwarded traffic on a router
> (net.ipv4.ip_forward enabled on IPv4, net.ipv6.conf.all.forwarding on
> IPv6).
ICMP errors about forwarded traffic are sent to the originator of the
quoted packet. The router forwards them and they never reach udp_err().
The forwarding sysctl is irrelevant here.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 0:31 [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts Tom
2026-11-26 0:32 ` netdev-bot+sinfo
2026-11-26 0:33 ` Tom
2026-11-26 8:04 ` Ido Schimmel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®