From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v5 1/2] s390/zcrypt: Improve CCA CPRB length and overflow checks
Date: Fri, 24 Jul 2026 15:39:23 +0000 [thread overview]
Message-ID: <20260724153924.278291F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724151616.147765-2-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Integer overflow in EP11 length calculation bypasses bounds check, leading to DoS.
- [High] Missing minimum size validation and uninitialized padding memory leak in EP11 message processing.
--
--- Patch [1]: [PATCH v5 1/2] s390/zcrypt: Improve CCA CPRB length and overflow checks ---
commit db060c7765ef46ae0c3f096c8f02b7e395cb8a36
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/zcrypt: Improve CCA CPRB length and overflow checks
This commit fixes several security vulnerabilities in the CCA CPRB message
processing function by adding minimum size validation, fixing integer
overflows during alignment, and preventing memory leaks by zeroing trailing
bytes.
> diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c
> index 40f72cdf284d3..2e4aef330b680 100644
> --- a/drivers/s390/crypto/zcrypt_msgtype6.c
> +++ b/drivers/s390/crypto/zcrypt_msgtype6.c
> @@ -342,49 +342,40 @@ static int xcrb_msg_to_type6cprb_msgx(bool userspace, struct ap_message *ap_msg,
> };
> } __packed * msg = ap_msg->msg;
>
> - int rcblen = CEIL4(xcrb->request_control_blk_length);
> - int req_sumlen, resp_sumlen;
> - char *req_data = ap_msg->msg + sizeof(struct type6_hdr) + rcblen;
> - char *function_code;
> + size_t req_cblen, rep_cblen, req_sumlen, rep_sumlen;
> + char *function_code, *req_data;
>
> - if (CEIL4(xcrb->request_control_blk_length) <
> - xcrb->request_control_blk_length)
> - return -EINVAL; /* overflow after alignment*/
> -
> - /* length checks */
> + /* request length and overflow checks */
> + if (xcrb->request_control_blk_length < sizeof(struct CPRBX))
> + return -EINVAL;
[Severity: High]
This isn't a bug introduced by this patch, but does the same missing size
validation issue exist in the EP11 counterpart
xcrb_msg_to_type6_ep11cprb_msgx() in the same file?
In xcrb_msg_to_type6_ep11cprb_msgx():
ap_msg->len = sizeof(struct type6_hdr) + CEIL4(xcrb->req_len);
Without a minimum size check on xcrb->req_len (e.g., against
sizeof(struct ep11_cprb)), could this parse uninitialized kernel memory from
ap_init_apmsg() if userspace passes a very small length via the
ZSENDEP11CPRB ioctl?
Later in the same function:
if (msg->cprbx.flags & 0x80)
ap_msg->flags |= AP_MSG_FLAG_ADMIN;
Could this uninitialized memory dictate administration privileges, or leak
uninitialized padding to the hardware?
> + req_cblen = CEIL4((size_t)xcrb->request_control_blk_length);
> + if (req_cblen > U32_MAX)
> + return -EINVAL;
> ap_msg->len = sizeof(struct type6_hdr) +
> - CEIL4(xcrb->request_control_blk_length) +
> - xcrb->request_data_length;
> + req_cblen + xcrb->request_data_length;
> if (ap_msg->len > ap_msg->bufsize)
> return -EINVAL;
[Severity: Critical]
This is a pre-existing issue, but could the lack of an overflow check in
xcrb_msg_to_type6_ep11cprb_msgx() lead to a denial of service?
In xcrb_msg_to_type6_ep11cprb_msgx(), the length calculation lacks similar
boundary checks:
ap_msg->len = sizeof(struct type6_hdr) + CEIL4(xcrb->req_len);
if (ap_msg->len > ap_msg->bufsize)
return -EINVAL;
If a local user supplies a massive value for xcrb->req_len
(e.g., 0xFFFFFFFFFFFFFFF0), could CEIL4() wrap around a 64-bit boundary,
resulting in a small length that bypasses the bufsize check?
If bypassed, it would reach the copy operation:
if (z_copy_from_user(userspace, msg->userdata,
(char __force __user *)xcrb->req, xcrb->req_len)) {
When copy_from_user() fails its access_ok check with this massive length,
would it execute memset(..., 0, 0xFFFFFFFFFFFFFFF0), causing an
out-of-bounds write that immediately panics the kernel?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724151616.147765-1-freude@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-07-24 15:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 15:16 [PATCH v5 0/2] Improve code in zcrypt msg type 6 handling Harald Freudenberger
2026-07-24 15:16 ` [PATCH v5 1/2] s390/zcrypt: Improve CCA CPRB length and overflow checks Harald Freudenberger
2026-07-24 15:39 ` sashiko-bot [this message]
2026-07-24 15:16 ` [PATCH v5 2/2] s390/zcrypt: Improve EP11 " Harald Freudenberger
2026-07-24 15:57 ` 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=20260724153924.278291F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=freude@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