nvmet-tcp: fix header digest verification
authorAmit Engel <amit.engel@dell.com>
Wed, 27 Oct 2021 06:49:27 +0000 (09:49 +0300)
committerChristoph Hellwig <hch@lst.de>
Wed, 27 Oct 2021 07:20:50 +0000 (09:20 +0200)
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>
drivers/nvme/target/tcp.c

index 586ca20..46c3b3b 100644 (file)
@@ -1096,7 +1096,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;
        }