Re: [PATCH v2] nvme-tcp: fix connect failure on receiving partial ICResp PDU

From: Maurizio Lombardi
Date: Fri Jan 24 2025 - 03:09:04 EST


čt 23. 1. 2025 v 23:50 odesílatel Caleb Sander Mateos
<csander@xxxxxxxxxxxxxxx> napsal:
>
> 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);
> goto free_icresp;
> }

There is a small problem here, suppose ret is a positive number but
smaller than sizeof(*icresp),
you will print a bogus error code, then you "goto free_icresp;" and
return this random positive number to the caller.

I think that if ret > 0 you should set it to -EINVAL.

Maurizio