From: sashiko-bot@kernel.org
To: "Eric Farman" <farman@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH v8 01/10] s390/vfio_ccw: free all memory if cp_init() fails
Date: Tue, 28 Jul 2026 01:51:22 +0000 [thread overview]
Message-ID: <20260728015122.AA9821F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728013509.1551753-2-farman@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Unbounded recursion in CCW chain processing allows a malicious guest to overflow the host kernel stack.
- [High] Off-by-one out-of-bounds read in `ccwchain_calc_length()`.
--
--- Patch [1]: [PATCH v8 01/10] s390/vfio_ccw: free all memory if cp_init() fails ---
commit 7b177e824046c97e78d70a5cb8daa7a37e59333e
Author: Eric Farman <farman@linux.ibm.com>
s390/vfio_ccw: free all memory if cp_init() fails
This commit addresses a memory leak in the channel program cleanup logic.
By moving the cleanup outside of the recursive handling functions, it
ensures all segments created by Transfer in Channel operations are
properly freed when initialization fails.
> diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
> index 7561aa7d3e017..086d1b54bdb05 100644
> --- a/drivers/s390/cio/vfio_ccw_cp.c
> +++ b/drivers/s390/cio/vfio_ccw_cp.c
> @@ -455,9 +455,6 @@ static int ccwchain_handle_ccw(dma32_t cda, struct channel_program *cp)
> /* Loop for tics on this new chain. */
> ret = ccwchain_loop_tic(chain, cp);
[Severity: Critical]
This is a pre-existing issue, but does this recursive call chain allow a
guest to trigger unbounded recursion and exhaust the host kernel stack?
Looking at the code execution path:
drivers/s390/cio/vfio_ccw_cp.c:ccwchain_handle_ccw()
ret = ccwchain_loop_tic(chain, cp);
drivers/s390/cio/vfio_ccw_cp.c:ccwchain_loop_tic()
ret = ccwchain_handle_ccw(tic->cda, cp);
If a guest constructs a channel program with a long sequence of Transfer
In Channel (TIC) instructions, each pointing to a distinct CCW chain
memory address, tic_target_chain_exists() will return false.
Could this cause ccwchain_loop_tic() to recursively call
ccwchain_handle_ccw() for each segment without any depth limits, leading
to a guest-to-host denial of service?
[Severity: High]
This isn't a bug introduced by this patch, but is there an off-by-one
out-of-bounds read in ccwchain_calc_length() which is called earlier in
this function?
ccwchain_handle_ccw() calls ccwchain_calc_length(), which has the following
loop condition:
drivers/s390/cio/vfio_ccw_cp.c:ccwchain_calc_length() {
...
} while (cnt < CCWCHAIN_LEN_MAX + 1);
...
}
Since guest_cp is allocated with exactly CCWCHAIN_LEN_MAX elements (256),
when cnt becomes 257 during the iteration, evaluating the ccw pointer
accesses guest_cp[256].
If a guest submits a chain of exactly CCWCHAIN_LEN_MAX length with the
command-chaining flag enabled on the last element, could this read past the
end of the allocation and potentially oops if it hits an unmapped page?
> - if (ret)
> - ccwchain_free(chain);
> -
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260728013509.1551753-1-farman@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-07-28 1:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 1:34 [PATCH v8 00/10] s390/vfio_ccw fixes Eric Farman
2026-07-28 1:35 ` [PATCH v8 01/10] s390/vfio_ccw: free all memory if cp_init() fails Eric Farman
2026-07-28 1:51 ` sashiko-bot [this message]
2026-07-28 1:35 ` [PATCH v8 02/10] s390/vfio_ccw: limit the number of channel program segments Eric Farman
2026-07-28 1:52 ` sashiko-bot
2026-07-28 1:35 ` [PATCH v8 03/10] s390/vfio_ccw: fix out of bounds check on CCW array Eric Farman
2026-07-28 1:50 ` sashiko-bot
2026-07-28 1:35 ` [PATCH v8 04/10] s390/vfio_ccw: ensure first IDAW remains constant Eric Farman
2026-07-28 1:45 ` sashiko-bot
2026-07-28 1:35 ` [PATCH v8 05/10] s390/vfio_ccw: calculate idal length based on idaw type Eric Farman
2026-07-28 1:49 ` sashiko-bot
2026-07-28 1:35 ` [PATCH v8 06/10] s390/vfio_ccw: ensure index for read/write regions are within range Eric Farman
2026-07-28 1:54 ` sashiko-bot
2026-07-28 1:35 ` [PATCH v8 07/10] s390/vfio_ccw: cancel existing workqueues Eric Farman
2026-07-28 1:53 ` sashiko-bot
2026-07-28 2:07 ` Matthew Rosato
2026-07-28 1:35 ` [PATCH v8 08/10] s390/vfio_ccw: move cp cleanup out of not operational Eric Farman
2026-07-28 1:49 ` sashiko-bot
2026-07-28 2:08 ` Matthew Rosato
2026-07-28 3:23 ` Eric Farman
2026-07-28 1:35 ` [PATCH v8 09/10] s390/vfio_ccw: selectively expand io_mutex Eric Farman
2026-07-28 1:57 ` sashiko-bot
2026-07-28 2:08 ` Matthew Rosato
2026-07-28 1:35 ` [PATCH v8 10/10] s390/vfio_ccw: implement a crw lock Eric Farman
2026-07-28 2:01 ` 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=20260728015122.AA9821F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=farman@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--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