DPDK patches and discussions
 help / color / mirror / Atom feed
From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: maxime.coquelin@redhat.com, Fan Zhang <roy.fan.zhang@intel.com>,
	david.marchand@redhat.com
Subject: [PATCH v2] vhost/crypto: fix out of bound access
Date: Fri,  8 Jul 2022 13:59:14 +0000	[thread overview]
Message-ID: <20220708135914.137368-1-roy.fan.zhang@intel.com> (raw)
In-Reply-To: <20220708134923.136101-1-roy.fan.zhang@intel.com>

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


      reply	other threads:[~2022-07-08 13:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08 13:49 [PATCH] " Fan Zhang
2022-07-08 13:59 ` Fan Zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220708135914.137368-1-roy.fan.zhang@intel.com \
    --to=roy.fan.zhang@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).