nvmet-tcp: fix header digest verification
authorAmit Engel <amit.engel@dell.com>
Wed, 27 Oct 2021 06:49:27 +0000 (09:49 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 13:03:43 +0000 (14:03 +0100)
[ Upstream commit 86aeda32b887cdaeb0f4b7bfc9971e36377181c7 ]

Pass the correct length to nvmet_tcp_verify_hdgst, which is the pdu
header length.  This fixes a wrong behaviour where header digest
verification passes although the digest is wrong.

Signed-off-by: Amit Engel <amit.engel@dell.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/tcp.c

index b4ef7e9..58dc517 100644 (file)
@@ -1084,7 +1084,7 @@ recv:
        }
 
        if (queue->hdr_digest &&
-           nvmet_tcp_verify_hdgst(queue, &queue->pdu, queue->offset)) {
+           nvmet_tcp_verify_hdgst(queue, &queue->pdu, hdr->hlen)) {
                nvmet_tcp_fatal_error(queue); /* fatal */
                return -EPROTO;
        }