From: cfzhu Date: Thu, 21 Mar 2019 17:35:18 +0000 (+0800) Subject: QAT: Allocate digest_buffer using QAT_PHYS_CONTIG_ALLOC() X-Git-Tag: zfs-0.8.0-rc4~56 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45001b949c14b09230a4cd6d105ab32a4673d286;p=zfs QAT: Allocate digest_buffer using QAT_PHYS_CONTIG_ALLOC() 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 Reviewed-by: Tom Caputi Signed-off-by: Chengfei, Zhu Closes #8323 Closes #8521 --- diff --git a/module/zfs/qat_crypt.c b/module/zfs/qat_crypt.c index 98d837713..5a5113e68 100644 --- a/module/zfs/qat_crypt.c +++ b/module/zfs/qat_crypt.c @@ -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);