Received: from eggs.gnu.org ([2001:4830:134:3::10]:55429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVdP1-0007ys-PV for qemu-devel@nongnu.org; Wed, 11 Mar 2015 05:58:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVdOu-0001EO-RQ for qemu-devel@nongnu.org; Wed, 11 Mar 2015 05:58:11 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:44664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVdOu-0001ED-HF for qemu-devel@nongnu.org; Wed, 11 Mar 2015 05:58:04 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Mar 2015 09:58:03 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 53E0E219005C for ; Wed, 11 Mar 2015 09:57:52 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2B9w1k963569934 for ; Wed, 11 Mar 2015 09:58:01 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2B9w0V0017591 for ; Wed, 11 Mar 2015 03:58:01 -0600 From: Cornelia Huck Date: Wed, 11 Mar 2015 10:57:51 +0100 Message-Id: <1426067871-17693-3-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1426067871-17693-1-git-send-email-cornelia.huck@de.ibm.com> References: <1426067871-17693-1-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <20150310180526.2149b5c2.cornelia.huck@de.ibm.com> References: <20150310180526.2149b5c2.cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH 2/2] virtio-ccw: assure be accesses for set-revision List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mst@redhat.com Cc: Cornelia Huck , thuth@linux.vnet.ibm.com, qemu-devel@nongnu.org All fields in structures transmitted by ccws are big endian; assure we handle them as such for the set-revision ccw as well. Should be merged into "s390x/virtio-ccw: add virtio set-revision call". CC: Thomas Huth Signed-off-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 60f8a14..a64f116 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -687,7 +687,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) break; case CCW_CMD_SET_VIRTIO_REV: len = sizeof(revinfo); - if (ccw.count < len || (check_len && ccw.count > len)) { + if (ccw.count < sizeof(revinfo)) { ret = -EINVAL; break; } @@ -695,7 +695,18 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret = -EFAULT; break; } - cpu_physical_memory_read(ccw.cda, &revinfo, len); + revinfo.revision = lduw_be_phys(&address_space_memory, ccw.cda); + revinfo.length = lduw_be_phys(&address_space_memory, + ccw.cda + sizeof(revinfo.revision)); + if (ccw.count < len + revinfo.length || + (check_len && ccw.count > len + revinfo.length)) { + ret = -EINVAL; + break; + } + /* + * Once we start to support revisions with additional data, we'll + * need to fetch it here. Nothing to do for now, though. + */ if (dev->revision >= 0 || revinfo.revision > virtio_ccw_rev_max(dev)) { ret = -ENOSYS; -- 2.1.4