]> granicus.if.org Git - zfs/commitdiff
QAT: Allocate digest_buffer using QAT_PHYS_CONTIG_ALLOC()
authorcfzhu <chengfeix.zhu@intel.com>
Thu, 21 Mar 2019 17:35:18 +0000 (01:35 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 21 Mar 2019 17:35:18 +0000 (10:35 -0700)
If the buffer 'digest_buffer' is allocated in the qat_checksum()
stack, it can't ensure that the address is physically contiguous,
and the DMA result of the buffer may be handled incorrectly.
Using QAT_PHYS_CONTIG_ALLOC() ensures a physically
contiguous allocation.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Signed-off-by: Chengfei, Zhu <chengfeix.zhu@intel.com>
Closes #8323
Closes #8521

module/zfs/qat_crypt.c

index 98d837713dd76e9b36c7049683ea97b62a3cbca2..5a5113e68a5e1b40bcdc6e773801186bef0999d1 100644 (file)
@@ -455,7 +455,7 @@ qat_checksum(uint64_t cksum, uint8_t *buf, uint64_t size, zio_cksum_t *zcp)
        Cpa8S *data = NULL;
        CpaCySymSessionCtx *cy_session_ctx = NULL;
        cy_callback_t cb;
-       Cpa8U digest_buffer[sizeof (zio_cksum_t)];
+       Cpa8U *digest_buffer = NULL;
        CpaCySymOpData op_data = { 0 };
        CpaBufferList src_buffer_list = { 0 };
        CpaFlatBuffer *flat_src_buf_array = NULL;
@@ -494,6 +494,10 @@ qat_checksum(uint64_t cksum, uint8_t *buf, uint64_t size, zio_cksum_t *zcp)
            nr_bufs * sizeof (CpaFlatBuffer));
        if (status != CPA_STATUS_SUCCESS)
                goto fail;
+       status = QAT_PHYS_CONTIG_ALLOC(&digest_buffer,
+           sizeof (zio_cksum_t));
+       if (status != CPA_STATUS_SUCCESS)
+               goto fail;
 
        bytes_left = size;
        data = buf;
@@ -530,6 +534,10 @@ qat_checksum(uint64_t cksum, uint8_t *buf, uint64_t size, zio_cksum_t *zcp)
                status = CPA_STATUS_FAIL;
                goto fail;
        }
+       if (cb.verify_result == CPA_FALSE) {
+               status = CPA_STATUS_FAIL;
+               goto fail;
+       }
 
        bcopy(digest_buffer, zcp, sizeof (zio_cksum_t));
 
@@ -541,6 +549,7 @@ fail:
                kunmap(in_pages[i]);
 
        cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx);
+       QAT_PHYS_CONTIG_FREE(digest_buffer);
        QAT_PHYS_CONTIG_FREE(src_buffer_list.pPrivateMetaData);
        QAT_PHYS_CONTIG_FREE(cy_session_ctx);
        QAT_PHYS_CONTIG_FREE(flat_src_buf_array);