Re: [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts

From: Tom

Date: Sat Nov 28 2026 - 07:54:35 EST


Hello Ido,

> This is intentional. See commit 4c3499f79f8c ("ipv4: udp: Create
> exceptions before socket matching") and commit ac76cab50e89 ("ipv6: udp:
> Create exceptions before socket matching").

Thank you for the review and for pointing me to commits 4c3499f79f8c and
ac76cab50e89.

> 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.

How could an off-path attacker probe the FNHE cache to discover the
ephemeral port of a connected UDP socket? Prior to ac76cab and
ac76cab50e89.

Thanks.







Best regards,
Tomas


Il giorno gio 26 nov 2026 alle ore 09:04 Ido Schimmel
<idosch@xxxxxxxxxx> ha scritto:
>
> 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.