qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: mrhines@linux.vnet.ibm.com
To: qemu-devel@nongnu.org
Cc: yamahata@private.email.ne.jp, aliguori@us.ibm.com,
	quintela@redhat.com, frank.yangjie@gmail.com,
	owasserm@redhat.com, mrhines@us.ibm.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH v2 for-1.6 1/6] rdma: use resp.len after validation in qemu_rdma_registration_stop
Date: Fri,  9 Aug 2013 16:05:40 -0400	[thread overview]
Message-ID: <1376078746-24948-2-git-send-email-mrhines@linux.vnet.ibm.com> (raw)
In-Reply-To: <1376078746-24948-1-git-send-email-mrhines@linux.vnet.ibm.com>

From: Isaku Yamahata <yamahata@private.email.ne.jp>

resp.len is given from remote host. So should be validated before use.
Otherwise memcpy can access beyond the buffer.

Cc: Michael R. Hines <mrhines@us.ibm.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
 migration-rdma.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/migration-rdma.c b/migration-rdma.c
index 3a380d4..6721266 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -3045,10 +3045,6 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
             return ret;
         }
 
-        qemu_rdma_move_header(rdma, reg_result_idx, &resp);
-        memcpy(rdma->block,
-            rdma->wr_data[reg_result_idx].control_curr, resp.len);
-
         nb_remote_blocks = resp.len / sizeof(RDMARemoteBlock);
 
         /*
@@ -3070,6 +3066,9 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
             return -EINVAL;
         }
 
+        qemu_rdma_move_header(rdma, reg_result_idx, &resp);
+        memcpy(rdma->block,
+            rdma->wr_data[reg_result_idx].control_curr, resp.len);
         for (i = 0; i < nb_remote_blocks; i++) {
             network_to_remote_block(&rdma->block[i]);
 
-- 
1.7.10.4

  reply	other threads:[~2013-08-09 20:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 20:05 [Qemu-devel] [PATCH v2 for-1.6 0/6] rdma: uh oh! IPv6 broken in linux - need workaround mrhines
2013-08-09 20:05 ` mrhines [this message]
2013-08-09 20:05 ` [Qemu-devel] [PATCH v2 for-1.6 2/6] rdma: validate RDMAControlHeader::len mrhines
2013-08-09 20:05 ` [Qemu-devel] [PATCH v2 for-1.6 3/6] rdma: check if RDMAControlHeader::len match transferred byte mrhines
2013-08-09 20:05 ` [Qemu-devel] [PATCH v2 for-1.6 4/6] rdma: proper getaddrinfo() handling mrhines
2013-08-09 20:05 ` [Qemu-devel] [PATCH v2 for-1.6 5/6] rdma: IPv6 over Ethernet (RoCE) is broken in linux - workaround mrhines
2013-08-09 20:05 ` [Qemu-devel] [PATCH v2 for-1.6 6/6] rdma: remaining documentation fixes mrhines
2013-08-09 20:26   ` Eric Blake
2013-08-09 20:32     ` Michael R. Hines
2013-08-09 20:36       ` Eric Blake
2013-08-14 16:27 ` [Qemu-devel] [PATCH v2 for-1.6 0/6] rdma: uh oh! IPv6 broken in linux - need workaround Anthony Liguori

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=1376078746-24948-2-git-send-email-mrhines@linux.vnet.ibm.com \
    --to=mrhines@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=frank.yangjie@gmail.com \
    --cc=mrhines@us.ibm.com \
    --cc=owasserm@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=yamahata@private.email.ne.jp \
    /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).