From: Lin Ma <linma@zju.edu.cn>
To: David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>
Cc: netdev@vger.kernel.org, linux-afs@lists.infradead.org,
linux-kernel@vger.kernel.org, Lin Ma <linma@zju.edu.cn>
Subject: [PATCH net v2] rxrpc: Fix NULL Tx buffer handling in the retransmission path
Date: Sat, 28 Nov 2026 10:44:27 +0800 [thread overview]
Message-ID: <20261128024427.306409-1-linma@zju.edu.cn> (raw)
rxrpc_retransmit_data() can be handed a NULL txb in two ways.
First, rxrpc_transmit_fresh_data() commits the Tx queue state before
rxrpc_send_data_packet() has prepared the packet. If the wire header
allocation fails, tx_transmitted is not advanced, and the next pass
builds req.seq from tx_transmitted but req.tq from the new tail segment.
Indexing that segment with the stale sequence number can select a NULL or
wrong txbuf. If the LAST packet was in the unsent batch, the Tx phase
can also be closed with packets that were never sent.
Second, rxrpc_input_ackall() rotates the Tx window and frees txbufs up to
tx_transmitted, but it doesn't advance acks_hard_ack. A subsequent TLP
expiry can therefore select an in-range but already-freed slot.
Fix the first by only committing tx_qtail and tx_top after
rxrpc_send_data_packet() has advanced tx_transmitted, and by arming a
short retry timer if it didn't. Fix the second by advancing
acks_hard_ack on ACKALL. Also make rxrpc_retransmit_data() tolerate a
missing txbuf as a final guard, and retain the lower-bound check in
rxrpc_resend_tlp().
Fixes: b341a0263b1b ("rxrpc: Implement progressive transmission queue struct")
Fixes: 7c482665931b6 ("rxrpc: Implement RACK/TLP to deal with transmission stalls [RFC8985]")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
Changes in v2:
- Only commit tx_qtail and tx_top after rxrpc_send_data_packet() has
advanced tx_transmitted, and retry after a short delay if the wire
header allocation failed, instead of only guarding the TLP fast path.
- Advance acks_hard_ack on ACKALL and tolerate a missing txbuf.
Link: https://lore.kernel.org/all/20261122135515.3989708-1-linma@zju.edu.cn/
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122135515.3989708-1-linma%40zju.edu.cn
net/rxrpc/call_event.c | 29 +++++++++++++++++++++++------
net/rxrpc/input.c | 7 +++++++
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index 21be9c86d7a7..2360e9289602 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -64,6 +64,9 @@ static bool rxrpc_retransmit_data(struct rxrpc_call *call,
unsigned int ix = req->seq & RXRPC_TXQ_MASK;
struct rxrpc_txbuf *txb = tq->bufs[ix];
+ if (!txb)
+ return false;
+
_enter("%x,%x,%x,%x", tq->qbase, req->seq, ix, txb->debug_id);
req->retrans = true;
@@ -141,6 +144,7 @@ void rxrpc_resend_tlp(struct rxrpc_call *call)
/* There's a chance it'll be on the tail segment of the queue. */
req.tq = READ_ONCE(call->tx_qtail);
if (req.tq &&
+ after_eq(call->tx_transmitted, req.tq->qbase) &&
before(call->tx_transmitted, req.tq->qbase + RXRPC_NR_TXQUEUE)) {
rxrpc_retransmit_data(call, &req);
return;
@@ -213,6 +217,7 @@ static void rxrpc_transmit_fresh_data(struct rxrpc_call *call, unsigned int limi
struct rxrpc_txbuf *txb;
rxrpc_seq_t send_top, seq;
int limit = min(space, max(call->peer->pmtud_jumbo, 1));
+ bool last;
/* Order send_top before the contents of the new txbufs and
* txqueue pointers
@@ -244,17 +249,29 @@ static void rxrpc_transmit_fresh_data(struct rxrpc_call *call, unsigned int limi
break;
} while (req.n < limit && before(seq, send_top));
+ last = txb->flags & RXRPC_LAST_PACKET;
+
if (__rxrpc_call_state(call) == RXRPC_CALL_CLIENT_PRE_SEND)
rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_SEND_REQUEST);
- if (txb->flags & RXRPC_LAST_PACKET) {
- rxrpc_close_tx_phase(call);
- tq = NULL;
+
+ rxrpc_send_data_packet(call, &req);
+
+ if (call->tx_transmitted != seq) {
+ /* The wire header allocation failed; retry shortly. */
+ ktime_t delay = ms_to_ktime(100);
+
+ call->rack_timer_mode = RXRPC_CALL_RACKTIMER_TLP_PTO;
+ call->rack_timo_at = ktime_add(ktime_get_real(), delay);
+ trace_rxrpc_timer_set(call, delay,
+ rxrpc_timer_trace_rack_tlp_pto);
+ break;
}
- call->tx_qtail = tq;
- call->tx_top = seq;
+ call->tx_qtail = last ? NULL : tq;
+ call->tx_top = seq;
+ if (last)
+ rxrpc_close_tx_phase(call);
space -= req.n;
- rxrpc_send_data_packet(call, &req);
}
}
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 73cafe6bfa9f..ee1073951c8d 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -1242,6 +1242,13 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb)
if (rxrpc_rotate_tx_window(call, call->tx_transmitted, &summary))
rxrpc_end_tx_phase(call, false, rxrpc_eproto_unexpected_ackall);
+
+ /* ACKALL acknowledges everything transmitted, but rotating the Tx
+ * window only advances tx_bottom. Advance the hard-ACK mark too so
+ * that a subsequent TLP probe doesn't select a freed Tx buffer.
+ */
+ if (after(call->tx_transmitted, call->acks_hard_ack))
+ call->acks_hard_ack = call->tx_transmitted;
}
/*
next reply other threads:[~2026-11-28 2:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 2:44 Lin Ma [this message]
2026-11-28 2:49 ` netdev-bot+sinfo
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=20261128024427.306409-1-linma@zju.edu.cn \
--to=linma@zju.edu.cn \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=netdev@vger.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
all inboxes | Powered by JetHome®