[PATCH] crypto/virtio: check for invalid IOVA address

Gowrishankar Muthukrishnan gmuthukrishn at marvell.com
Thu May 15 10:03:10 CEST 2025


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 at marvell.com>
---
 drivers/crypto/virtio/virtio_cryptodev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

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 *)
-- 
2.25.1



More information about the dev mailing list