Skip to contentSkip to conversation

nvmet-tcp: do not continue for invalid icreq

PATCH In review [email protected] 3 participants 3 messages Jan 12, 2024 – Jan 15, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet-tcp: do not continue for invalid icreq

From: Hannes Reinecke <[email protected]>

When the length check for an icreq sqe fails we should not continue processing but rather return immediately as all other contents of that sqe cannot be relied on.

---
 drivers/nvme/target/tcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/target/tcp.c +1 -0
index 6a1e6bb80062..3d606ab01506 100644
@@ -898,6 +898,7 @@ static int nvmet_tcp_handle_icreq(struct nvmet_tcp_queue *queue)
 		pr_err("bad nvme-tcp pdu length (%d)\n",
 			le32_to_cpu(icreq->hdr.plen));
 		nvmet_tcp_fatal_error(queue);
+		return -EPROTO;
 	}
 
 	if (icreq->pfv != NVME_TCP_PFV_1_0) {
Signature · 1 line
2.35.3
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 5 lines · On 1/11/24 23:23, [email protected] wrote:

From: Hannes Reinecke <[email protected]>

When the length check for an icreq sqe fails we should not continue processing but rather return immediately as all other contents of that sqe cannot be relied on.

above can be restructured at the time of applying the patch :-

When the length check for an icreq sqe fails we should not continue processing but rather return immediately as all other contents of the sqe cannot be relied on.

Quoted 10 lines
---
  drivers/nvme/target/tcp.c | 1 +
  1 file changed, 1 insertion(+)
drivers/nvme/target/tcp.c +0 -0
index 6a1e6bb80062..3d606ab01506 100644

drivers/nvme/target/tcp.c static int nvmet_tcp_handle_icreq(struct nvmet_tcp_queue *queue) · line 904

Quoted 7 lines
drivers/nvme/target/tcp.c +1 -0
@@ -898,6 +898,7 @@ static int nvmet_tcp_handle_icreq(struct nvmet_tcp_queue *queue)
  		pr_err("bad nvme-tcp pdu length (%d)\n",
  			le32_to_cpu(icreq->hdr.plen));
  		nvmet_tcp_fatal_error(queue);
+		return -EPROTO;
  	}
 
  	if (icreq->pfv != NVME_TCP_PFV_1_0) {

Looks good.

-ck