mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Tom <tomasbortoli@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	dsahern@kernel.org, eric.dumazet@gmail.com, kuba@kernel.org,
	willemdebruijn.kernel@gmail.com,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] udp: don't apply socketless ICMP PMTU/redirect updates on end hosts
Date: Thu, 26 Nov 2026 10:04:01 +0200	[thread overview]
Message-ID: <20261126080401.GA540848@shredder> (raw)
In-Reply-To: <CAAHj5qjM7BoGKD35gVCn_XCf6ec-LKq7-5_1YMewOYfskyATjQ@mail.gmail.com>

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.

      parent reply	other threads:[~2026-11-26  8:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  0:31 Tom
2026-11-26  0:32 ` netdev-bot+sinfo
2026-11-26  0:33   ` Tom
2026-11-26  8:04 ` Ido Schimmel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126080401.GA540848@shredder \
    --to=idosch@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tomasbortoli@gmail.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®