From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
qemu-s390x <qemu-s390x@nongnu.org>,
Halil Pasic <pasic@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Jason Herne <jjherne@linux.ibm.com>,
Richard Henderson <richard.henderson@linaro.org>,
Ilya Leoshkevich <iii@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Hendrik Brueckner <brueckner@linux.ibm.com>,
qemu-stable@nongnu.org, Farhan Ali <alifm@linux.ibm.com>
Subject: [PATCH v2 4/5] s390x/ioinst: Require strict length and format for SEI CHSC handler
Date: Tue, 7 Jul 2026 09:07:27 +0200 [thread overview]
Message-ID: <20260707070728.147203-5-borntraeger@linux.ibm.com> (raw)
In-Reply-To: <20260707070728.147203-1-borntraeger@linux.ibm.com>
From: Matthew Rosato <mjrosato@linux.ibm.com>
Ensure SEI commands that are received are of the appropriate length and
format before handling.
Cc: qemu-stable@nongnu.org
Fixes: 8cba80c3a0 ("s390: Add PCI bus support")
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Farhan Ali<alifm@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
target/s390x/ioinst.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c
index 2320dd4c12..94619f9215 100644
--- a/target/s390x/ioinst.c
+++ b/target/s390x/ioinst.c
@@ -609,13 +609,27 @@ static int chsc_sei_nt2_have_event(void)
#define CHSC_SEI_NT0 (1ULL << 63)
#define CHSC_SEI_NT2 (1ULL << 61)
+#define CHSC_SEI_0_FMT 0x0f000000
static void ioinst_handle_chsc_sei(ChscReq *req, ChscResp *res)
{
uint64_t selection_mask = ldq_be_p(&req->param1);
+ uint32_t param0 = be32_to_cpu(req->param0);
uint8_t *res_flags = (uint8_t *)res->data;
+ uint16_t len = be16_to_cpu(req->len);
+ uint16_t resp_code;
int have_event = 0;
int have_more = 0;
+ if (len != 0x0010) {
+ resp_code = 0x0003;
+ goto out_err;
+ }
+
+ if (param0 & CHSC_SEI_0_FMT) {
+ resp_code = 0x0007;
+ goto out_err;
+ }
+
/* regarding architecture nt0 can not be masked */
have_event = !chsc_sei_nt0_get_event(res);
have_more = chsc_sei_nt0_have_event();
@@ -642,6 +656,12 @@ static void ioinst_handle_chsc_sei(ChscReq *req, ChscResp *res)
res->code = cpu_to_be16(0x0005);
res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
}
+ return;
+
+ out_err:
+ res->code = cpu_to_be16(resp_code);
+ res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
+ res->param = 0;
}
static void ioinst_handle_chsc_unimplemented(ChscResp *res)
--
2.53.0
next prev parent reply other threads:[~2026-07-07 7:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 7:07 [PATCH v2 0/5] interface hardening fixes Christian Borntraeger
2026-07-07 7:07 ` [PATCH v2 1/5] s390x/sclp: reject invalid write event data headers Christian Borntraeger
2026-07-07 7:07 ` [PATCH v2 2/5] s390x/pci: Tighten region detection for BAR read/write Christian Borntraeger
2026-07-07 7:07 ` [PATCH v2 3/5] s390x/pci: Shrink RPCIT ranges to registered window Christian Borntraeger
2026-07-07 7:07 ` Christian Borntraeger [this message]
2026-07-07 7:07 ` [PATCH v2 5/5] s390x/css: limit number of CHPIDs in description Christian Borntraeger
2026-07-07 11:59 ` [PATCH v2 0/5] interface hardening fixes Cornelia Huck
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=20260707070728.147203-5-borntraeger@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@kernel.org \
--cc=farman@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.