crypto/ipsec_mb: fix usage of untrusted value

Message ID 20220307124802.1371808-1-piotrx.bronowski@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series crypto/ipsec_mb: fix usage of untrusted value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Piotr Bronowski March 7, 2022, 12:48 p.m. UTC
  This patch removes coverity defect CID 375828:
Untrusted value as argument (TAINTED_SCALAR)

Coverity issue: CID 375828
Fixes: 918fd2f1466b ("crypto/ipsec_mb: move aesni_mb PMD")

Signed-off-by: Piotr Bronowski <piotrx.bronowski@intel.com>
---
 drivers/crypto/ipsec_mb/pmd_aesni_gcm.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c b/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c
index e5ad629fe5..f735b77680 100644
--- a/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c
+++ b/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c
@@ -206,6 +206,9 @@  post_process_gcm_crypto_op(struct ipsec_mb_qp *qp,
 			op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 	} else {
 		if (session->req_digest_length != session->gen_digest_length) {
+			session->req_digest_length =
+				RTE_MIN(session->req_digest_length,
+						DIGEST_LENGTH_MAX);
 			if (session->op ==
 				IPSEC_MB_OP_AEAD_AUTHENTICATED_ENCRYPT)
 				memcpy(op->sym->aead.digest.data,