Skip to contentSkip to conversation

crypto/virtio: check for invalid IOVA address

PATCH Applied Gowrishankar Muthukrishnan 2 participants 2 messages May 15, 2025 – May 21, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/virtio: check for invalid IOVA address

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")
---
 drivers/crypto/virtio/virtio_cryptodev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/crypto/virtio/virtio_cryptodev.c +8 -0
index bc737f1e68..fa215fe528 100644
@@ -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 *)
Signature · 1 line
2.25.1