]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvme-tcp: fix signedness bug in nvme_tcp_init_connection()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 5 Mar 2025 15:52:59 +0000 (18:52 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 12:02:09 +0000 (13:02 +0100)
commit822c6a92d64c9c1044acf95df442a67fbc4212f7
treed36eb15a61705b68850b38278e845ae2bed00351
parentb5741e4b9ef3567613b2351384f91d3f16e59986
nvme-tcp: fix signedness bug in nvme_tcp_init_connection()

[ Upstream commit 528361c49962708a60f51a1afafeb00987cebedf ]

The kernel_recvmsg() function returns an int which could be either
negative error codes or the number of bytes received.  The problem is
that the condition:

        if (ret < sizeof(*icresp)) {

is type promoted to type unsigned long and negative values are treated
as high positive values which is success, when they should be treated as
failure.  Handle invalid positive returns separately from negative
error codes to avoid this problem.

Fixes: 578539e09690 ("nvme-tcp: fix connect failure on receiving partial ICResp PDU")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/tcp.c