Skip to content

Commit 30e32f3

Browse files
sagigrimbergChristoph Hellwig
authored andcommitted
nvmet-tcp: fix possible list corruption for unexpected command failure
nvmet_tcp_handle_req_failure needs to understand weather to prepare for incoming data or the next pdu. However if we misidentify this, we will wait for 0-length data, and queue the response although nvmet_req_init already did that. The particular command was namespace management command with no data, which was incorrectly categorized as a command with incapsule data. Also, add a code comment of what we are trying to do here. Signed-off-by: Sagi Grimberg <[email protected]> Reviewed-by: Keith Busch <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 8b77fa6 commit 30e32f3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/nvme/target/tcp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,14 @@ static void nvmet_tcp_handle_req_failure(struct nvmet_tcp_queue *queue,
922922
size_t data_len = le32_to_cpu(req->cmd->common.dptr.sgl.length);
923923
int ret;
924924

925-
if (!nvme_is_write(cmd->req.cmd) ||
925+
/*
926+
* This command has not been processed yet, hence we are trying to
927+
* figure out if there is still pending data left to receive. If
928+
* we don't, we can simply prepare for the next pdu and bail out,
929+
* otherwise we will need to prepare a buffer and receive the
930+
* stale data before continuing forward.
931+
*/
932+
if (!nvme_is_write(cmd->req.cmd) || !data_len ||
926933
data_len > cmd->req.port->inline_data_size) {
927934
nvmet_prepare_receive_pdu(queue);
928935
return;

0 commit comments

Comments
 (0)