From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Prasad J Pandit <pjp@fedoraproject.org>,
Qinghao Tang <luodalongde@gmail.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: [Qemu-devel] [PULL v2 04/19] virtio: add check for descriptor's mapped address
Date: Sat, 24 Sep 2016 01:04:40 +0300 [thread overview]
Message-ID: <1474668213-15643-5-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1474668213-15643-1-git-send-email-mst@redhat.com>
From: Prasad J Pandit <pjp@fedoraproject.org>
virtio back end uses set of buffers to facilitate I/O operations.
If its size is too large, 'cpu_physical_memory_map' could return
a null address. This would result in a null dereference while
un-mapping descriptors. Add check to avoid it.
Reported-by: Qinghao Tang <luodalongde@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
hw/virtio/virtio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index fcf3358..bb656b1 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -495,6 +495,11 @@ static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iove
}
iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);
+ if (!iov[num_sg].iov_base) {
+ error_report("virtio: bogus descriptor or out of resources");
+ exit(1);
+ }
+
iov[num_sg].iov_len = len;
addr[num_sg] = pa;
--
MST
next prev parent reply other threads:[~2016-09-23 22:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 22:04 [Qemu-devel] [PULL v2 00/19] virtio, pc: fixes and features Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 01/19] tests: add /vhost-user/connect-fail test Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 02/19] tests: add a simple /vhost-user/multiqueue test Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 03/19] tests: add /vhost-user/flags-mismatch test Michael S. Tsirkin
2016-09-23 22:04 ` Michael S. Tsirkin [this message]
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 05/19] pc: clean up COMPAT macro chaining Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 06/19] target-i386: turn off CPU.l3-cache only for 2.7 and older machine types Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 07/19] virtio: fix stray tab character Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 08/19] virtio: stop virtqueue processing if device is broken Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 09/19] virtio: migrate vdev->broken flag Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 10/19] virtio: handle virtqueue_map_desc() errors Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 11/19] virtio: handle virtqueue_get_avail_bytes() errors Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 12/19] virtio: use unsigned int for virtqueue_get_avail_bytes() index Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 13/19] virtio: handle virtqueue_read_next_desc() errors Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 14/19] virtio: handle virtqueue_num_heads() errors Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 15/19] virtio: handle virtqueue_get_head() errors Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 16/19] hw/pci: Prepare for AMD IOMMU Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 17/19] hw/i386/trace-events: Add AMD IOMMU trace events Michael S. Tsirkin
2016-09-23 22:04 ` [Qemu-devel] [PULL v2 18/19] hw/i386: Introduce AMD IOMMU Michael S. Tsirkin
2016-09-23 22:05 ` [Qemu-devel] [PULL v2 19/19] hw/i386: AMD IOMMU IVRS table Michael S. Tsirkin
2016-09-23 22:32 ` [Qemu-devel] [PULL v2 00/19] virtio, pc: fixes and features no-reply
2016-09-26 19:59 ` Peter Maydell
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=1474668213-15643-5-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=lersek@redhat.com \
--cc=luodalongde@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
/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).