From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPZ1i-0003FD-1d for qemu-devel@nongnu.org; Thu, 04 Sep 2014 11:32:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPZ1X-0000IY-5B for qemu-devel@nongnu.org; Thu, 04 Sep 2014 11:32:45 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:39544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPZ1W-0000I4-TQ for qemu-devel@nongnu.org; Thu, 04 Sep 2014 11:32:35 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Sep 2014 16:32:33 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id ACD191B08070 for ; Thu, 4 Sep 2014 16:33:32 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s84FWVUH46334014 for ; Thu, 4 Sep 2014 15:32:31 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s84FWUD2013265 for ; Thu, 4 Sep 2014 09:32:31 -0600 From: Jens Freimann Date: Thu, 4 Sep 2014 17:32:23 +0200 Message-Id: <1409844743-31009-4-git-send-email-jfrei@linux.vnet.ibm.com> In-Reply-To: <1409844743-31009-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1409844743-31009-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: 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 --- 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