nvmet_tcp: fix header digest verification
A message that is not in the archive (sent off-list or not yet received): [email protected]
Sagi Grimberg
maintainerQuoted 5 lines
pass the correct length to
nvmet_tcp_hdgst. whenverify_hdgst, need to pass pdu header len. This fixes a wrong behaviour where
header digest verification pass although digest is wrong
Amit, can you describe what you mean here?
what is wrong about the digest?
What is currently passed in len is queue->offset, which is the temporary offset from the pdu, which is equal to hdr->hlen because we verify the digest right after we finish reading the PDU header.
Quoted 11 lines
Signed-off-by Amit Engel <[email protected]>--- drivers/nvme/target/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/target/tcp.c +0
-0
drivers/nvme/target/tcp.c static int nvmet_tcp_verify_hdgst(struct nvmet_tcp_queue *queue, · line 271
Quoted 5 lines
drivers/nvme/target/tcp.c +1
-1@@ -268,7 +268,7 @@ static int nvmet_tcp_verify_hdgst(struct nvmet_tcp_queue *queue, } recv_digest = *(__le32 *)(pdu + hdr->hlen); -nvmet_tcp_hdgst (queue->rcv_hash, pdu, len); +nvmet_tcp_hdgst (queue->rcv_hash, pdu, hdr->hlen);
If at all, the caller should pass hdr->hlen and keep this generic.
One of our tests found that
With the current code,recv_digest == exp_digest even if the pdu header digest is being modified (synthetically)
For example:
In case that pdu header digest is changed to 0xffffffff, recv == exp == 0xfffffff, and nvmet_tcp_verify_hdgst returns 0 - which is wrong
Internal Use - Confidential
-----Original Message-----
From: Sagi Grimberg <[email protected]>
Sent: Tuesday, October 19, 2021 3:19 PM
To: Engel, Amit; [email protected]; [email protected]
Subject: Re: [PATCH] nvmet_tcp: fix header digest verification
[EXTERNAL EMAIL]
Quoted 4 lines
pass the correct length to
nvmet_tcp_hdgst. whenverify_hdgst, need to pass pdu header len. This fixes a wrong behaviour where
header digest verification pass although digest is wrong
Amit, can you describe what you mean here?
what is wrong about the digest?
What is currently passed in len is queue->offset, which is the temporary offset from the pdu, which is equal to hdr->hlen because we verify the digest right after we finish reading the PDU header.
Quoted 11 lines
Signed-off-by Amit Engel <[email protected]>--- drivers/nvme/target/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/target/tcp.c +0
-0
drivers/nvme/target/tcp.c static int nvmet_tcp_verify_hdgst(struct nvmet_tcp_queue *queue, · line 271
Quoted 5 lines
drivers/nvme/target/tcp.c +1
-1@@ -268,7 +268,7 @@ static int nvmet_tcp_verify_hdgst(struct nvmet_tcp_queue *queue, } recv_digest = *(__le32 *)(pdu + hdr->hlen); -nvmet_tcp_hdgst (queue->rcv_hash, pdu, len); +nvmet_tcp_hdgst (queue->rcv_hash, pdu, hdr->hlen);
If at all, the caller should pass hdr->hlen and keep this generic.
Sagi Grimberg
maintainerQuoted 6 lines
One of our tests found that
With the current code,recv_digest==exp_digesteven if the pdu header digest is being modified (synthetically)
For example:
In case that pdu header digest is changed to0xffffffff, recv == exp ==0xfffffff, andnvmet_tcp_verify_hdgstreturns 0 - which is wrong
Not sure I follow. Can you describe in which case the passed offset != hdr->hlen?
Quoted 1 line
Internal Use - Confidential
Is this confidential?
In nvmet_tcp_try_recv_pdu:
1. After kernel_recvmsg, 'queue->offset' is equal to 'sizeof(struct nvme_tcp_hdr)'
2. update queue->left = hdr->hlen - queue->offset + hdgst and 'goto recv'
3. after recvmsg , the offset is greater than the digest.
So , In this case offset != hdr->hlen
This will lead to nvmet_tcp_verify_hdgst to always pass, which
Thanks
Amit
Internal Use - Confidential
-----Original Message-----
From: Sagi Grimberg <[email protected]>
Sent: Wednesday, October 20, 2021 8:53 PM
To: Engel, Amit; [email protected]; [email protected]
Subject: Re: [PATCH] nvmet_tcp: fix header digest verification
[EXTERNAL EMAIL]
Quoted 6 lines
One of our tests found that
With the current code,recv_digest==exp_digesteven if the pdu header digest is being modified (synthetically) For example:
In case that pdu header digest is changed to0xffffffff, recv == exp ==0xfffffff, andnvmet_tcp_verify_hdgstreturns 0 - which is wrong
Not sure I follow. Can you describe in which case the passed offset != hdr->hlen?
Quoted 1 line
Internal Use - Confidential
Is this confidential?
Sagi Grimberg
maintainerQuoted 11 lines
In
nvmet_tcp_try_recv_pdu:
1. Afterkernel_recvmsg, 'queue->offset' is equal to 'sizeof(struct nvme_tcp_hdr)'2. update
queue->left=hdr->hlen-queue->offset+ hdgst and 'goto recv'3. after recvmsg , the offset is greater than the digest.
So , In this case offset !=
hdr->hlenThis will lead to
nvmet_tcp_verify_hdgstto always pass, which
I see, so the patch should modify the call-site to nvmet_tcp_verify_hdgst to pass in hdr->hlen.
Quoted 6 lines
Thanks
AmitInternal Use - Confidential
You should remove this footer from your emails to the public mailing list...
Thank you Sagi. I just sent the patch
Amit
-----Original Message-----
From: Sagi Grimberg <[email protected]>
Sent: Tuesday, October 26, 2021 6:35 PM
To: Engel, Amit; [email protected]; [email protected]
Subject: Re: [PATCH] nvmet_tcp: fix header digest verification
[EXTERNAL EMAIL]
Quoted 10 lines
In
nvmet_tcp_try_recv_pdu:
1. Afterkernel_recvmsg, 'queue->offset' is equal to 'sizeof(struct nvme_tcp_hdr)'2. update
queue->left=hdr->hlen-queue->offset+ hdgst and 'goto recv'3. after recvmsg , the offset is greater than the digest.
So , In this case offset !=
hdr->hlenThis will lead to
nvmet_tcp_verify_hdgstto always pass, which
I see, so the patch should modify the call-site to nvmet_tcp_verify_hdgst to pass in hdr->hlen.
Quoted 6 lines
Thanks
AmitInternal Use - Confidential
You should remove this footer from your emails to the public mailing list...