]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvme-tcp: fix connect failure on receiving partial ICResp PDU
authorCaleb Sander Mateos <csander@purestorage.com>
Fri, 24 Jan 2025 18:43:10 +0000 (11:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Feb 2025 12:30:20 +0000 (04:30 -0800)
commit020c50e314dcdf6b8c5027ff62571547e6da0e0b
tree49c162c9358f315d6ffe313c11b5899abd09718f
parent1070154b40bf4fc6316bf7e6eedf6d7e5ac8334d
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@purestorage.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/tcp.c