[PATCH v2 0/2] nvme-tcp: fix the R2T send/receive race
Zhenwen Liang
zhenwenliang at google.com
Mon Nov 23 21:10:39 PST 2026
nvme_tcp_handle_r2t() sets up the next H2CData transfer while the send
path may still be finishing the previous R2T of the same request. On
stable kernels (with the "<" offset check) this leaves pdu_sent wrong
and the write stalls until the I/O timeout; since 347d50d92e25 on
v7.4-rc4 the host rejects the valid R2T and reconnects.
Patch 1/2 fixes a 32-bit overflow in the existing R2T length check.
Patch 2/2 moves the R2T setup to the send path.
Changes since v1, with the Sashiko review findings:
- 32-bit overflow in the length checks -> patch 1/2 (and the new check
in 2/2 uses the same form).
- Use-after-completion on send error -> 2/2: the send error path no
longer completes a request that the receive path has queued again;
error recovery handles it.
- Race with a second R2T / torn read of the recorded R2T -> 2/2: one
R2T at a time (NVME_TCP_REQ_R2T_BUSY), published with
NVME_TCP_REQ_R2T_READY. The send path never sets up an R2T before
the command PDU has been sent completely; if it finds a recorded R2T
for a request whose command PDU has not been sent
(NVME_TCP_REQ_CMD_SENT), it treats it as a protocol error.
Test results are in the notes of 2/2. I am open to a smaller approach
if that is preferred.
v1: https://lore.kernel.org/r/20261123225246.1653658-1-zhenwenliang@google.com
The problem was found with a Lean-based formal model of the code and
AI-assisted analysis. The patches and this text were written with AI
assistance and reviewed by a human.
Zhenwen Liang (2):
nvme-tcp: avoid overflow in the R2T length check
nvme-tcp: set up R2T data transfer in the send path
drivers/nvme/host/tcp.c | 132 +++++++++++++++++++++++++++++++++++++---
1 file changed, 122 insertions(+), 10 deletions(-)
More information about the Linux-nvme
mailing list