Received: from eggs.gnu.org ([208.118.235.92]:56240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVI94-0002iz-Pm for qemu-devel@nongnu.org; Thu, 25 Apr 2013 05:07:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVI8y-00049F-Dp for qemu-devel@nongnu.org; Thu, 25 Apr 2013 05:07:14 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:57281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVI8y-00048w-2n for qemu-devel@nongnu.org; Thu, 25 Apr 2013 05:07:08 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Apr 2013 10:03:57 +0100 From: Cornelia Huck Date: Thu, 25 Apr 2013 11:06:55 +0200 Message-Id: <1366880815-26431-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1366880815-26431-1-git-send-email-cornelia.huck@de.ibm.com> References: <1366880815-26431-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH] virtio-ccw: Check indicators location. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: Blue Swirl , Cornelia Huck , Anthony Liguori , qemu-stable@nongnu.org, =?UTF-8?q?Aur=C3=A9lien=20Jarno?= If a guest neglected to register (secondary) indicators but still runs with notifications enabled, we might end up writing to guest zero; avoid this by checking for valid indicators and only writing to the guest and generating an interrupt if indicators have been setup. Cc: qemu-stable@nongnu.org Signed-off-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 56e4872..b857413 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -742,10 +742,16 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector) } if (vector < VIRTIO_PCI_QUEUE_MAX) { + if (!dev->indicators) { + return; + } indicators = ldq_phys(dev->indicators); indicators |= 1ULL << vector; stq_phys(dev->indicators, indicators); } else { + if (!dev->indicators2) { + return; + } vector = 0; indicators = ldq_phys(dev->indicators2); indicators |= 1ULL << vector; -- 1.7.9.5