From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPo1y-0002XA-Bj for qemu-devel@nongnu.org; Fri, 05 Sep 2014 03:34:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPo1n-0006yf-GZ for qemu-devel@nongnu.org; Fri, 05 Sep 2014 03:34:02 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:33129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPo1n-0006yW-7f for qemu-devel@nongnu.org; Fri, 05 Sep 2014 03:33:51 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 Sep 2014 08:33:50 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8B4302190063 for ; Fri, 5 Sep 2014 08:33:28 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s857XlVP43843614 for ; Fri, 5 Sep 2014 07:33:47 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s857XlZs005008 for ; Fri, 5 Sep 2014 01:33:47 -0600 From: Jens Freimann Date: Fri, 5 Sep 2014 09:33:18 +0200 Message-Id: <1409902398-22028-4-git-send-email-jfrei@linux.vnet.ibm.com> In-Reply-To: <1409902398-22028-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1409902398-22028-1-git-send-email-jfrei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 3/3] s390x/css: catch ccw sequence errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christian Borntraeger , Alexander Graf , Cornelia Huck Cc: Jens Freimann , qemu-devel@nongnu.org From: Cornelia Huck We must not allow chains of more than 255 ccws without data transfer. Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck Signed-off-by: Jens Freimann --- hw/s390x/css.c | 10 ++++++++++ hw/s390x/css.h | 1 + 2 files changed, 11 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 34637cb..b67c039 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -294,6 +294,13 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr) check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC)); + if (!ccw.cda) { + if (sch->ccw_no_data_cnt == 255) { + return -EINVAL; + } + sch->ccw_no_data_cnt++; + } + /* Look at the command. */ switch (ccw.cmd_code) { case CCW_CMD_NOOP: @@ -396,6 +403,7 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb) return; } sch->ccw_fmt_1 = !!(orb->ctrl0 & ORB_CTRL0_MASK_FMT); + sch->ccw_no_data_cnt = 0; } else { s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND); } @@ -1358,6 +1366,7 @@ void subch_device_save(SubchDev *s, QEMUFile *f) qemu_put_be16(f, s->id.ciw[i].count); } qemu_put_byte(f, s->ccw_fmt_1); + qemu_put_byte(f, s->ccw_no_data_cnt); return; } @@ -1414,6 +1423,7 @@ int subch_device_load(SubchDev *s, QEMUFile *f) s->id.ciw[i].count = qemu_get_be16(f); } s->ccw_fmt_1 = qemu_get_byte(f); + s->ccw_no_data_cnt = qemu_get_byte(f); return 0; } diff --git a/hw/s390x/css.h b/hw/s390x/css.h index 384a455..33104ac 100644 --- a/hw/s390x/css.h +++ b/hw/s390x/css.h @@ -78,6 +78,7 @@ struct SubchDev { bool last_cmd_valid; bool ccw_fmt_1; bool thinint_active; + uint8_t ccw_no_data_cnt; /* transport-provided data: */ int (*ccw_cb) (SubchDev *, CCW1); SenseId id; -- 1.8.5.5