Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] nvme-tcp: fix the R2T send/receive race
@ 2026-11-24  5:10 Zhenwen Liang
  2026-11-24  5:10 ` [PATCH v2 1/2] nvme-tcp: avoid overflow in the R2T length check Zhenwen Liang
  2026-11-24  5:10 ` [PATCH v2 2/2] nvme-tcp: set up R2T data transfer in the send path Zhenwen Liang
  0 siblings, 2 replies; 4+ messages in thread
From: Zhenwen Liang @ 2026-11-24  5:10 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
  Cc: Shao Mingyin, linux-nvme


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(-)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-24  5:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  5:10 [PATCH v2 0/2] nvme-tcp: fix the R2T send/receive race Zhenwen Liang
2026-11-24  5:10 ` [PATCH v2 1/2] nvme-tcp: avoid overflow in the R2T length check Zhenwen Liang
2026-11-24  5:10 ` [PATCH v2 2/2] nvme-tcp: set up R2T data transfer in the send path Zhenwen Liang
2026-11-24  5:35   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox