diff options
author | cfzhu <[email protected]> | 2019-03-22 01:35:18 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-03-21 10:35:18 -0700 |
commit | 45001b949c14b09230a4cd6d105ab32a4673d286 (patch) | |
tree | 6022b6ba5b7505525d2a1b8a789c05beddbc8e34 | |
parent | ec4f9b8f30391a3fb46c8d4a31c2dc9250dca1bb (diff) |
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 <[email protected]>
Reviewed-by: Tom Caputi <[email protected]>
Signed-off-by: Chengfei, Zhu <[email protected]>
Closes #8323
Closes #8521
-rw-r--r-- | module/zfs/qat_crypt.c | 11 |
1 files changed, 10 insertions, 1 deletions
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); |