nvme-tcp: fix the R2T send/receive race
Get series with b4
b4 am [email protected]Versions newest first
- v2 Latest2 patches 0 repliesNew
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | nvme-tcp: avoid overflow in the R2T length checkdrivers/ | +1 | 0 replies | |
| 2/2 | nvme-tcp: set up R2T data transfer in the send pathdrivers/ | +122 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] nvme-tcp: fix the R2T send/receive race
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/[email protected]
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(-)