From: sashiko-bot@kernel.org
To: "Alexander Egorenkov" <egorenar@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v7 1/5] s390/sclp: Make parsing of received event buffers more robust
Date: Wed, 23 Sep 2026 07:52:33 +0000 [thread overview]
Message-ID: <20260923075233.691EC1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260923074006.3962077-2-egorenar@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] s390/sclp: TOCTOU double fetch of sccb->length and evbuf->length
--
commit d21cb539ad66b7cd19d44f1b8944ce8a000b730d
Author: Alexander Egorenkov <egorenar@linux.ibm.com>
s390/sclp: Make parsing of received event buffers more robust
Validate header fields of SCCB and event buffers to protect from potential
out-of-range memory accesses which might be caused by malformed hardware
responses.
> diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c
> index 98e334724a627..5a4e4001dfa8d 100644
> --- a/drivers/s390/char/sclp.c
> +++ b/drivers/s390/char/sclp.c
> @@ -532,8 +532,7 @@ EXPORT_SYMBOL(sclp_add_request);
>
> /* Dispatch events found in request buffer to registered listeners. Return 0
> * if all events were dispatched, non-zero otherwise. */
> -static int
> -sclp_dispatch_evbufs(struct sccb_header *sccb)
> +static int sclp_dispatch_evbufs(struct sccb_header *sccb)
> {
> unsigned long flags;
> struct evbuf_header *evbuf;
> @@ -542,14 +541,25 @@ sclp_dispatch_evbufs(struct sccb_header *sccb)
> int offset;
> int rc;
>
> + /* Check for malformed hardware response */
> + if (sccb->length > PAGE_SIZE)
> + return -EINVAL;
> +
[Severity: High]
In drivers/s390/char/sclp.c:sclp_dispatch_evbufs(), is it possible for a
malicious hypervisor to mutate sccb->length after this initial validation?
Since sccb points to DMA shared memory, this validation is performed outside
the sclp_lock.
> spin_lock_irqsave(&sclp_lock, flags);
> rc = 0;
> for (offset = sizeof(struct sccb_header); offset < sccb->length;
> offset += evbuf->length) {
[Severity: High]
Does spin_lock_irqsave() act as a full compiler barrier here, forcing
sccb->length and evbuf->length to be re-fetched from shared memory on each loop
iteration?
If a malicious hypervisor mutates the lengths (e.g., setting sccb->length >
PAGE_SIZE or evbuf->length = 0) between the initial bounds checks and these
re-fetches, could it bypass the mitigation and cause out-of-bounds memory
reads or infinite loops?
> - evbuf = (struct evbuf_header *) ((addr_t) sccb + offset);
> /* Check for malformed hardware response */
> - if (evbuf->length == 0)
> + if (offset + sizeof(struct evbuf_header) > sccb->length) {
> + rc = -EINVAL;
> break;
> + }
> + evbuf = (struct evbuf_header *) ((addr_t) sccb + offset);
> + if (evbuf->length < sizeof(*evbuf) ||
> + offset + evbuf->length > sccb->length) {
[Severity: High]
Do subsequent re-fetches of sccb->length and evbuf->length in these bounds
checks continue to expose a double-fetch TOCTOU window?
Because memory barriers like function calls or locking/unlocking occur during
the rest of the loop, the compiler may be forced to repeatedly fetch these
values from untrusted shared memory.
> + rc = -EINVAL;
> + break;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923074006.3962077-1-egorenar@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-09-23 7:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 7:40 [PATCH v7 0/5] s390/sclp: Misc fixes Alexander Egorenkov
2026-09-23 7:40 ` [PATCH v7 1/5] s390/sclp: Make parsing of received event buffers more robust Alexander Egorenkov
2026-09-23 7:52 ` sashiko-bot [this message]
2026-09-23 7:40 ` [PATCH v7 2/5] s390/sclp: Introduce macro sclp_gds_for_each() Alexander Egorenkov
2026-09-23 7:52 ` sashiko-bot
2026-09-23 10:57 ` Christian Borntraeger
2026-09-23 7:40 ` [PATCH v7 3/5] s390/sclp_tty: Make use of sclp_gds_for_each() Alexander Egorenkov
2026-09-23 7:52 ` sashiko-bot
2026-09-23 7:40 ` [PATCH v7 4/5] s390/sclp_ocf: Fix computation of length of GDS values Alexander Egorenkov
2026-09-23 7:49 ` sashiko-bot
2026-09-23 7:40 ` [PATCH v7 5/5] s390/sclp: Ensure no callback gets called after sclp_unregister() returns Alexander Egorenkov
2026-09-23 7:51 ` sashiko-bot
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=20260923075233.691EC1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=egorenar@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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