From: Jens Freimann <jfrei@linux.vnet.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>,
Alexander Graf <agraf@suse.de>,
Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] s390x/css: catch ccw sequence errors
Date: Thu, 4 Sep 2014 17:32:23 +0200 [thread overview]
Message-ID: <1409844743-31009-4-git-send-email-jfrei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1409844743-31009-1-git-send-email-jfrei@linux.vnet.ibm.com>
From: Cornelia Huck <cornelia.huck@de.ibm.com>
We must not allow chains of more than 255 ccws without data transfer.
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
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
next prev parent reply other threads:[~2014-09-04 15:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-04 15:32 [Qemu-devel] [PATCH 0/3] s390x: css patches and small sclp cleanup Jens Freimann
2014-09-04 15:32 ` [Qemu-devel] [PATCH 1/3] s390x: remove duplicate defines in SCLP code Jens Freimann
2014-09-04 15:32 ` [Qemu-devel] [PATCH 2/3] s390x/css: support format-0 ccws Jens Freimann
2014-09-04 22:29 ` Alexander Graf
2014-09-05 7:23 ` Christian Borntraeger
2014-09-05 7:25 ` Alexander Graf
2014-09-04 15:32 ` Jens Freimann [this message]
2014-09-04 17:58 ` [Qemu-devel] [PATCH 0/3] s390x: css patches and small sclp cleanup Christian Borntraeger
-- strict thread matches above, loose matches on Subject: below --
2014-09-05 7:33 [Qemu-devel] [PATCH 0/3 RESEND] " Jens Freimann
2014-09-05 7:33 ` [Qemu-devel] [PATCH 3/3] s390x/css: catch ccw sequence errors Jens Freimann
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=1409844743-31009-4-git-send-email-jfrei@linux.vnet.ibm.com \
--to=jfrei@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--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).