From: Jun Yang <juny24602@gmail.com>
To: dhowells@redhat.com, marc.dionne@auristor.com
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org,
linux-afs@lists.infradead.org, netdev@vger.kernel.org,
junvyyang@tencent.com, corvus@tencent.com, stable@kernel.org
Subject: [PATCH net] rxrpc: Fix kvec overflow when padding a path-MTU probe ACK
Date: Wed, 25 Nov 2026 15:16:38 +0800 [thread overview]
Message-ID: <20261125071652.56790-1-juny24602@gmail.com> (raw)
From: Jun Yang <junvyyang@tencent.com>
rxrpc_send_ACK() pads a PMTUD PING ACK out to call->peer->pmtud_trial +
sizeof(struct rxrpc_wire_header) by appending one PAGE_SIZE zeropage kvec
per page. The table it fills is call->local->kvec[], sized
1 + RXRPC_MAX_NR_JUMBO == 47 entries so that it can also hold a
maximum-size jumbo DATA packet. rxrpc_alloc_ack() has already used three
entries, so only 44 zeropage entries fit, and the loop has no upper
bound: a probe larger than 44 * PAGE_SIZE writes past the end of the
rxrpc_local allocation.
pmtud_trial can be driven that large because rxrpc_assess_MTU_size()
takes the peer MTU straight from dst_mtu(). An IPv4 output XFRM policy
with an unresolvable ESP template makes xfrm_lookup_route() return a
blackhole dst; ipv4_blackhole_route() points it at the loopback device
and dst_blackhole_mtu() returns dst_dev(dst)->mtu without the
IP_MAX_MTU clamp that ip_dst_mtu_maybe_forward() applies to ordinary
IPv4 dsts. With loopback's MTU raised inside a netns,
peer->pmtud_bad = if_mtu - hdrsize + 1 becomes huge and the probe search
in rxrpc_input_probe_for_pmtud() moves pmtud_trial far beyond 64K.
The XFRM policy only has to match the sport 7001 / dport 7000 that
rxrpc_assess_MTU_size() hardcodes, so it blackholes the route assessment
without affecting the call's own packets. CAP_NET_ADMIN in a new netns
is enough, which an unprivileged user obtains with
unshare(CLONE_NEWUSER|CLONE_NEWNET).
Clamp the route MTU to the maximum size of an IP datagram in
rxrpc_assess_MTU_size(), which keeps pmtud_bad bounded, and skip the
probe altogether in rxrpc_send_ACK() if its padding would not fit the
kvec table.
BUG: KASAN: slab-out-of-bounds in rxrpc_send_ACK (net/rxrpc/output.c:333)
Write of size 8 at addr ffff8880312f3630 by task krxrpcio/0/10441
Call Trace:
rxrpc_send_ACK (net/rxrpc/output.c:333)
rxrpc_input_call_event (net/rxrpc/call_event.c:484)
Fixes: eeaedc5449d9 ("rxrpc: Implement path-MTU probing using padded PING ACKs (RFC8899)")
Cc: stable@kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Signed-off-by: Jun Yang <junvyyang@tencent.com>
---
A KASAN reproducer for this issue is available if requested.
net/rxrpc/output.c | 4 ++++
net/rxrpc/peer_object.c | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index 88cad087f13b..57fae49e9ce8 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -327,6 +327,10 @@ void rxrpc_send_ACK(struct rxrpc_call *call, u8 ack_reason,
if (len > probe_mtu)
goto skip;
+ /* The zeropage padding must fit in the kvec table. */
+ if (probe_mtu - len >
+ (ARRAY_SIZE(call->local->kvec) - nr_kv) * PAGE_SIZE)
+ goto skip;
while (len < probe_mtu) {
size_t part = umin(probe_mtu - len, PAGE_SIZE);
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index fa9a406e1168..310fe94d9f6c 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -156,6 +156,7 @@ void rxrpc_assess_MTU_size(struct rxrpc_local *local, struct rxrpc_peer *peer)
struct rtable *rt;
struct flowi fl;
struct flowi4 *fl4 = &fl.u.ip4;
+ unsigned int max_mtu;
#ifdef CONFIG_AF_RXRPC_IPV6
struct flowi6 *fl6 = &fl.u.ip6;
#endif
@@ -179,6 +180,7 @@ void rxrpc_assess_MTU_size(struct rxrpc_local *local, struct rxrpc_peer *peer)
return;
}
dst = &rt->dst;
+ max_mtu = IP_MAX_MTU;
break;
#ifdef CONFIG_AF_RXRPC_IPV6
@@ -195,6 +197,7 @@ void rxrpc_assess_MTU_size(struct rxrpc_local *local, struct rxrpc_peer *peer)
_leave(" [route err %d]", dst->error);
return;
}
+ max_mtu = IP6_MAX_MTU;
break;
#endif
@@ -202,7 +205,8 @@ void rxrpc_assess_MTU_size(struct rxrpc_local *local, struct rxrpc_peer *peer)
BUG();
}
- peer->if_mtu = dst_mtu(dst);
+ /* A blackhole dst reports the device MTU with no IP_MAX_MTU clamp. */
+ peer->if_mtu = umin(dst_mtu(dst), max_mtu);
peer->hdrsize += dst->header_len + dst->trailer_len;
peer->tx_seg_max = dst->dev->gso_max_segs;
dst_release(dst);
base-commit: c5de2ce2fccdb7d3b48946179634eaa3d7ce2e7e
prerequisite-patch-id: 73dc5424c05c31bf826b8438dff12ad2acee90e4
--
2.56.1
reply other threads:[~2026-11-25 7:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261125071652.56790-1-juny24602@gmail.com \
--to=juny24602@gmail.com \
--cc=corvus@tencent.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=junvyyang@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=marc.dionne@auristor.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@kernel.org \
/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