rxrpc: Fix max_data reduction on an oversized ICMPv6 PTB
Subsystems (3)
PATCH 1/1 rxrpc: Fix max_data reduction on an oversized ICMPv6 PTB
From: Andrew Stellman <[email protected]>
rxrpc_adjust_mtu() computes max_t(int, mtu - peer->hdrsize, 500) on unsigned values, so a difference of 2^31 or more turns negative and is floored to 500. An ICMPv6 Packet Too Big with MTU 0xfffffff0 cut a peer's max_data from 1440 to 500. Compare the payload size as unsigned and keep the 500 floor for MTUs at or below the header size. Oversized PTBs no longer reduce max_data.
---
Tested on mainline 693c2e04e3f1 in arm64 QEMU with KASAN: an ICMPv6 PTB with MTU 0xfffffff0 cut max_data from 1440 to 500 before the patch and left it at 1440 after.
Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook) running Claude Opus 5.5; the fix was drafted with OpenAI GPT-6 (Codex).
A reproducer is available on request.
net/rxrpc/peer_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/rxrpc/peer_event.c +4 -1
@@ -122,7 +122,10 @@ static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, unsigned int mtu) } } - 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
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] rxrpc_adjust_mtu() in net/rxrpc/peer_event.c: when the ICMP carries no MTU (mtu == 0), the function estimates one with `mtu =…
- [Low] The note that the bug was found with an AI-driven tool (Quality Playbook running Claude) and that the fix was drafted with an AI…
--
rxrpc: Fix max_data reduction on an oversized ICMPv6 PTB
This patch changes the max_data calculation in rxrpc_adjust_mtu(). The old code was max_t(int, mtu - peer->hdrsize, 500). The new code is an explicit unsigned comparison against hdrsize followed by max(..., 500U). With this, an oversized ICMPv6 Packet Too Big no longer floors max_data to 500.
Quoted 4 lines
Fixes eeaedc5449d9 ("rxrpc: Implement path-MTU probing using padded PING ACKs (RFC8899)")Signed-off-by Andrew Stellman <[email protected]>---
[ ... ]
Quoted 3 lines
Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook) running Claude Opus 5.5; the fix was drafted with OpenAI GPT-6 (Codex).
[Severity: Low]
This isn't a bug, but the tool disclosure is below the --- separator, so git am drops it. The applied commit message ends at the Signed-off-by line.
Documentation/process/generated-content.rst says:
if a tool was used to find a problem addressed by a change, that should be noted in the changelog.
Could the note that the bug was found and the fix drafted with these tools be moved into the commit message body?
Quoted 5 lines
net/rxrpc/peer_event.c +0
-0
net/rxrpc/peer_event.c static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, unsigned int mtu) · line 129
Quoted 9 lines
net/rxrpc/peer_event.c +4
-1@@ -122,7 +122,10 @@ static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, unsigned int mtu) } } - 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) {
[Severity: Medium]
Does this change lose the 500 floor when the estimated MTU wraps in the mtu == 0 path? Earlier in rxrpc_adjust_mtu():
if (mtu == 0) {
/* they didn't give us a size, estimate one */
mtu = peer->if_mtu;
if (mtu > 1500) {
...
} else {
mtu -= 100;
if (mtu < peer->hdrsize)
mtu = peer->hdrsize + 4;
}
}If peer->if_mtu is below 100, mtu -= 100 wraps to about 0xffffffxx. The unsigned mtu < peer->hdrsize check can't catch that.
Before this patch, max_t(int, mtu - peer->hdrsize, 500) read the wrapped difference as negative and gave 500.
With the new code, mtu <= peer->hdrsize is false, and max(mtu - peer->hdrsize, 500U) gives roughly 0xffffff7e. That makes max_data < peer->max_data false, so the reduction is skipped. So are the pmtud_good/pmtud_bad clamps and trace_rxrpc_pmtud_reduce().
There are two ways if_mtu can end up below 100.
First, when peer->if_mtu == 65535, an ICMP FRAG_NEEDED or ICMPv6 PTB with 0 < mtu < 100 sets if_mtu to that value at the top of rxrpc_adjust_mtu(). If max_data was already 500 or less at that point (for example after an ACK trailer advertised maxMTU 500), pmtud_good and pmtud_bad are not clamped. rxrpc_input_probe_for_pmtud() can then raise max_data above 500 again.
Second, rxrpc_assess_MTU_size() does:
peer->if_mtu = dst_mtu(dst); peer->hdrsize += dst->header_len + dst->trailer_len;
A small route MTU or xfrm overhead can leave if_mtu below hdrsize, with max_data = RXRPC_JUMBO(1).
In either state, a later zero-MTU ICMP that reaches the function via rxrpc_encap_err_rcv()->rxrpc_input_error()->rxrpc_adjust_mtu(peer, 0) used to cut max_data to 500. Now it has no effect.
The commit message says "keep the 500 floor for MTUs at or below the header size". Does that still hold when the estimate goes below zero?
Would guarding the subtraction keep the intended floor? Something like:
if (mtu < peer->hdrsize + 100) mtu = peer->hdrsize + 4; else mtu -= 100;
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202181319.74045-1-bugs%40stellman-greene.com