Patch "nvme-tcp: fix connect failure on receiving partial ICResp PDU" has been added to the 6.13-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nvme-tcp: fix connect failure on receiving partial ICResp PDU

to the 6.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nvme-tcp-fix-connect-failure-on-receiving-partial-ic.patch
and it can be found in the queue-6.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9921ba9ee511b5dde31d3d0a926ebcedeec76e1b
Author: Caleb Sander Mateos <csander@xxxxxxxxxxxxxxx>
Date:   Fri Jan 24 11:43:10 2025 -0700

    nvme-tcp: fix connect failure on receiving partial ICResp PDU
    
    [ Upstream commit 578539e0969028f711c34d9a4565931edfe1d730 ]
    
    nvme_tcp_init_connection() attempts to receive an ICResp PDU but only
    checks that the return value from recvmsg() is non-negative. If the
    sender closes the TCP connection or sends fewer than 128 bytes, this
    check will pass even though the full PDU wasn't received.
    
    Ensure the full ICResp PDU is received by checking that recvmsg()
    returns the expected 128 bytes.
    
    Additionally set the MSG_WAITALL flag for recvmsg(), as a sender could
    split the ICResp over multiple TCP frames. Without MSG_WAITALL,
    recvmsg() could return prematurely with only part of the PDU.
    
    Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
    Signed-off-by: Caleb Sander Mateos <csander@xxxxxxxxxxxxxxx>
    Reviewed-by: Sagi Grimberg <sagi@xxxxxxxxxxx>
    Reviewed-by: Hannes Reinecke <hare@xxxxxxx>
    Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 4162893d49395..d7c193028e7c3 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1449,11 +1449,14 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
 		msg.msg_control = cbuf;
 		msg.msg_controllen = sizeof(cbuf);
 	}
+	msg.msg_flags = MSG_WAITALL;
 	ret = kernel_recvmsg(queue->sock, &msg, &iov, 1,
 			iov.iov_len, msg.msg_flags);
-	if (ret < 0) {
+	if (ret < sizeof(*icresp)) {
 		pr_warn("queue %d: failed to receive icresp, error %d\n",
 			nvme_tcp_queue_id(queue), ret);
+		if (ret >= 0)
+			ret = -ECONNRESET;
 		goto free_icresp;
 	}
 	ret = -ENOTCONN;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux