crypto/virtio: check for invalid IOVA address

Message ID 20250515080313.1612-1-gmuthukrishn@marvell.com (mailing list archive)
State Accepted
Delegated to: akhil goyal
Headers
Series crypto/virtio: check for invalid IOVA address |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/aws-unit-testing success Unit Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing warning Testing issues
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Gowrishankar Muthukrishnan May 15, 2025, 8:03 a.m. UTC
This change fixes coverity issue on overflowed constant.
Bad phys address should be checked before using it in
descriptor.

Coverity issue: 457462, 457465
Fixes: 10702138f1a ("crypto/virtio: support asymmetric RSA")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/crypto/virtio/virtio_cryptodev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Akhil Goyal May 21, 2025, 9:18 a.m. UTC | #1
> This change fixes coverity issue on overflowed constant.
> Bad phys address should be checked before using it in
> descriptor.
> 
> Coverity issue: 457462, 457465
> Fixes: 10702138f1a ("crypto/virtio: support asymmetric RSA")
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Cc: stable@dpdk.org
Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied to dpdk-next-crypto
Thanks
  

Patch

diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index bc737f1e68..fa215fe528 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -799,6 +799,10 @@  virtio_crypto_clear_session(
 	}
 
 	malloc_phys_addr = rte_malloc_virt2iova(ctrl);
+	if (malloc_phys_addr == RTE_BAD_IOVA) {
+		VIRTIO_CRYPTO_SESSION_LOG_ERR("malloc_phys_addr is invalid");
+		return;
+	}
 
 	/* status part */
 	status = &(((struct virtio_crypto_inhdr *)
@@ -916,6 +920,10 @@  virtio_crypto_clear_session_packed(
 	}
 
 	malloc_phys_addr = rte_malloc_virt2iova(ctrl);
+	if (malloc_phys_addr == RTE_BAD_IOVA) {
+		VIRTIO_CRYPTO_SESSION_LOG_ERR("malloc_phys_addr is invalid");
+		return;
+	}
 
 	/* status part */
 	status = &(((struct virtio_crypto_inhdr *)