Skip to contentSkip to conversation

rxrpc: Fix max_data reduction on an oversized ICMPv6 PTB

PATCH New Andrew Stellman 1 participant 1 message Dec 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rxrpc: Fix max_data reduction on an oversized ICMPv6 PTB

From: Andrew Stellman <[email protected]>

rxrpc_adjust_mtu() computes max_data with max_t(int, mtu - peer->hdrsize, 500), so an oversized MTU in an ICMPv6 PTB makes mtu - peer->hdrsize negative and reduces max_data to 500. Comparing as unsigned exposes a second wrap: when the ICMP gives no MTU and if_mtu is below 100, mtu -= 100 wraps and the 500-byte floor is skipped. Compare as unsigned and check the estimate before subtracting 100.

The issue was found by Claude Opus 5.5 running Quality Playbook, an LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex), this changelog with OpenAI GPT-6 (Codex) and Claude Opus 5.5, and both were reviewed by me.

Fixes eeaedc5449d9 ("rxrpc: Implement path-MTU probing using padded PING ACKs (RFC8899)")

---
v1: https://lore.kernel.org/netdev/[email protected]/
v2: Also guard the MTU estimate when the ICMP gives no MTU, as Sashiko's review of v1 pointed out.

Tested on net 90ae4042bd9f in arm64 QEMU with KASAN: an oversized PTB changed max_data from 1440 to 500 on base and left it at 1440 on v2; with a test-only if_mtu=80 hook, a zero-MTU PTB left it at 1440 on v1 and reduced it to 500 on v2.
A reproducer is available on request.

 net/rxrpc/peer_event.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
net/rxrpc/peer_event.c +7 -3
index 9d02448ac062..3b1ee4f6aa5a 100644
@@ -116,13 +116,17 @@ static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, unsigned int mtu)
 			if (mtu < 1500)
 				mtu = 1500;
 		} else {
-			mtu -= 100;
-			if (mtu < peer->hdrsize)
+			if (mtu < peer->hdrsize + 100)
 				mtu = peer->hdrsize + 4;
+			else
+				mtu -= 100;
 		}
 	}
 
-	max_data = max_t(int, mtu - peer->hdrsize, 500);
+	if (mtu <= peer->hdrsize)
+		max_data = 500;
+	else
+		max_data = max(mtu - peer->hdrsize, 500U);
 	if (max_data < peer->max_data) {
 		if (peer->pmtud_good > max_data)
 			peer->pmtud_good = max_data;
Signature · 1 line
2.53.0