From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V76NG-0004Id-ST for qemu-devel@nongnu.org; Wed, 07 Aug 2013 12:14:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V76N8-0001QP-VA for qemu-devel@nongnu.org; Wed, 07 Aug 2013 12:14:10 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:52614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V76N8-0001Pj-OM for qemu-devel@nongnu.org; Wed, 07 Aug 2013 12:14:02 -0400 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Aug 2013 10:14:02 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id E4BF11FF006F for ; Wed, 7 Aug 2013 10:08:33 -0600 (MDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r77GDtGv195474 for ; Wed, 7 Aug 2013 10:13:55 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r77GFjB7002372 for ; Wed, 7 Aug 2013 10:16:39 -0600 From: mrhines@linux.vnet.ibm.com Date: Wed, 7 Aug 2013 12:05:27 -0400 Message-Id: <1375891530-13759-2-git-send-email-mrhines@linux.vnet.ibm.com> In-Reply-To: <1375891530-13759-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1375891530-13759-1-git-send-email-mrhines@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH for-1.6 1/4] rdma: use resp.len after validation in qemu_rdma_registration_stop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: yamahata@private.email.ne.jp, aliguori@us.ibm.com, quintela@redhat.com, owasserm@redhat.com, mrhines@us.ibm.com, pbonzini@redhat.com From: Isaku Yamahata resp.len is given from remote host. So should be validated before use. Otherwise memcpy can access beyond the buffer. Cc: Michael R. Hines Reviewed-by: Orit Wasserman Reviewed-by: Michael R. Hines Signed-off-by: Isaku Yamahata Signed-off-by: Michael R. Hines --- 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