From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgGxF-0001dR-VK for qemu-devel@nongnu.org; Mon, 11 Jul 2011 09:55:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QgGxE-0006Zr-Ja for qemu-devel@nongnu.org; Mon, 11 Jul 2011 09:55:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgGxE-0006Zi-57 for qemu-devel@nongnu.org; Mon, 11 Jul 2011 09:55:20 -0400 Date: Mon, 11 Jul 2011 16:55:42 +0300 From: "Michael S. Tsirkin" Message-ID: <20110711135542.GA23769@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] virtio: fix indirect descriptor buffer overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori We were previously allowing arbitrarily-long indirect descriptors, which could lead to a buffer overflow in qemu-kvm process. CVE-2011-2212 Signed-off-by: Michael S. Tsirkin --- hw/virtio.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index e6043de..8a6f38c 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -449,9 +449,17 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) struct iovec *sg; if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) { + if (elem->in_num >= ARRAY_SIZE(elem->in_sg)) { + error_report("Too many write descriptors in indirect table"); + exit(1); + } elem->in_addr[elem->in_num] = vring_desc_addr(desc_pa, i); sg = &elem->in_sg[elem->in_num++]; } else { + if (elem->out_num >= ARRAY_SIZE(elem->out_sg)) { + error_report("Too many read descriptors in indirect table"); + exit(1); + } elem->out_addr[elem->out_num] = vring_desc_addr(desc_pa, i); sg = &elem->out_sg[elem->out_num++]; } -- 1.7.5.53.gc233e