DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] vhost/crypto: fix out of bound access
@ 2022-07-08 13:49 Fan Zhang
  2022-07-08 13:59 ` [PATCH v2] " Fan Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Fan Zhang @ 2022-07-08 13:49 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, Fan Zhang, david.marchand

Coverity issue: 379211

Fixes: 4414bb67010d ("vhost/crypto: fix build with GCC 12")
Cc: david.marchand@redhat.com

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 lib/vhost/vhost_crypto.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index 54946f46d9..e9c3322d20 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -574,12 +574,11 @@ copy_data_from_desc(void *dst, struct vhost_crypto_data_req *vc_req,
 
 	remain = RTE_MIN(desc->len, size);
 	addr = desc->addr;
-	do {
-		uint64_t len;
-		void *src;
 
-		len = remain;
-		src = IOVA_TO_VVA(void *, vc_req, addr, &len, VHOST_ACCESS_RO);
+        while (remain) {
+                uint64_t len = remain;
+		void *src = IOVA_TO_VVA(void *, vc_req, addr, &len, VHOST_ACCESS_RO);
+
 		if (unlikely(src == NULL || len == 0))
 			return 0;
 
@@ -588,7 +587,7 @@ copy_data_from_desc(void *dst, struct vhost_crypto_data_req *vc_req,
 		/* cast is needed for 32-bit architecture */
 		dst = RTE_PTR_ADD(dst, (size_t)len);
 		addr += len;
-	} while (unlikely(remain != 0));
+        }
 
 	return RTE_MIN(desc->len, size);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] vhost/crypto: fix out of bound access
  2022-07-08 13:49 [PATCH] vhost/crypto: fix out of bound access Fan Zhang
@ 2022-07-08 13:59 ` Fan Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Fan Zhang @ 2022-07-08 13:59 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, Fan Zhang, david.marchand

Coverity issue: 379211

Fixes: 4414bb67010d ("vhost/crypto: fix build with GCC 12")
Cc: david.marchand@redhat.com

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
v2: 
  fix format-warning

 lib/vhost/vhost_crypto.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index 54946f46d9..bf899d2a50 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -574,12 +574,11 @@ copy_data_from_desc(void *dst, struct vhost_crypto_data_req *vc_req,
 
 	remain = RTE_MIN(desc->len, size);
 	addr = desc->addr;
-	do {
-		uint64_t len;
-		void *src;
 
-		len = remain;
-		src = IOVA_TO_VVA(void *, vc_req, addr, &len, VHOST_ACCESS_RO);
+	while (remain) {
+		uint64_t len = remain;
+		void *src = IOVA_TO_VVA(void *, vc_req, addr, &len, VHOST_ACCESS_RO);
+
 		if (unlikely(src == NULL || len == 0))
 			return 0;
 
@@ -588,7 +587,7 @@ copy_data_from_desc(void *dst, struct vhost_crypto_data_req *vc_req,
 		/* cast is needed for 32-bit architecture */
 		dst = RTE_PTR_ADD(dst, (size_t)len);
 		addr += len;
-	} while (unlikely(remain != 0));
+	}
 
 	return RTE_MIN(desc->len, size);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-08 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 13:49 [PATCH] vhost/crypto: fix out of bound access Fan Zhang
2022-07-08 13:59 ` [PATCH v2] " Fan Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).