From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v7 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks
Date: Wed, 29 Jul 2026 10:40:29 +0000 [thread overview]
Message-ID: <20260729104030.62DF11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729095318.184141-3-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch addresses integer overflow and uninitialized memory read vulnerabilities in the CCA CPRB processing function (`xcrb_msg_to_type6cprb_msgx`), but completely overlooks the sibling function `xcrb_msg_to_type6_ep11cprb_msgx` which suffers from identical flaws.
--
--- Patch [2]: [PATCH v7 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks ---
commit 7ba0a2485f45508566e0f47333fa671569923db4
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/zcrypt: Improve CCA CPRB length and overflow checks
The xcrb_msg_to_type6cprb_msgx() function lacks proper input
validation, creating security vulnerabilities:
1. Integer overflow after CEIL4 alignment: Signed int variables could
overflow during 4-byte boundary alignment, causing undersized
buffer allocations or incorrect bounds checking.
2. Missing minimum size validation: The CPRBX structure is copied from
userspace without verifying sufficient buffer length. Undersized
buffers cause uninitialized memory access when reading structure
fields like cprbx.cprb_len and cprbx.domain.
3. Arithmetic overflow in sum calculations: Adding control block and
data block sizes could overflow, bypassing size checks and enabling
buffer overflows.
Fix by using size_t for length calculations, adding U32_MAX boundary
checks after alignment, validating minimum control block size before
copying from userspace, and detecting sum calculation overflows.
> diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c
> index 40f72cdf284d3..fb37e28c82424 100644
> --- a/drivers/s390/crypto/zcrypt_msgtype6.c
> +++ b/drivers/s390/crypto/zcrypt_msgtype6.c
[ ... ]
> @@ -437,10 +428,13 @@ static int xcrb_msg_to_type6cprb_msgx(bool userspace, struct ap_message *ap_msg,
> }
>
> /* copy data block */
> - if (xcrb->request_data_length &&
> - z_copy_from_user(userspace, req_data, xcrb->request_data_address,
> - xcrb->request_data_length))
> - return -EFAULT;
> + if (xcrb->request_data_length) {
> + req_data = ap_msg->msg + sizeof(struct type6_hdr) + req_cblen;
> + if (z_copy_from_user(userspace, req_data,
> + xcrb->request_data_address,
> + xcrb->request_data_length))
> + return -EFAULT;
> + }
>
> return 0;
> }
[Severity: High]
This isn't a bug introduced by this patch, but the sibling function
xcrb_msg_to_type6_ep11cprb_msgx() in this same file appears to suffer from
the exact same vulnerabilities being fixed here.
For example, when req_len is smaller than the required struct size,
z_copy_from_user() can complete successfully but leave trailing buffer
bytes uninitialized:
drivers/s390/crypto/zcrypt_msgtype6.c:xcrb_msg_to_type6_ep11cprb_msgx() {
...
if (z_copy_from_user(userspace, msg->userdata,
(char __force __user *)xcrb->req, xcrb->req_len)) {
return -EFAULT;
}
if ((msg->pld_lenfmt & 0x80) == 0x80) { /*ext.len.fmt 2 or 3*/
...
}
Because ap_msg->msg is allocated without zeroing, this reads uninitialized
kernel heap memory to perform routing and access control logic (like
domain, fcode, and whether the request requires admin or usage permission).
Additionally, CEIL4 can overflow for lengths near U64_MAX, bypassing
initial length checks.
Should xcrb_msg_to_type6_ep11cprb_msgx() also receive similar minimum
size validation and overflow checks?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729095318.184141-1-freude@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-07-29 10:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 9:53 [PATCH v7 0/5] Improve code in zcrypt msg type 6 handling Harald Freudenberger
2026-07-29 9:53 ` [PATCH v7 1/5] s390/zcrypt: Fix CPRB memory allocation in zcrypt misc code Harald Freudenberger
2026-07-29 10:15 ` sashiko-bot
2026-07-29 13:56 ` Harald Freudenberger
2026-07-29 9:53 ` [PATCH v7 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks Harald Freudenberger
2026-07-29 10:40 ` sashiko-bot [this message]
2026-07-29 9:53 ` [PATCH v7 3/5] s390/zcrypt: Improve EP11 " Harald Freudenberger
2026-07-29 10:49 ` sashiko-bot
2026-07-29 9:53 ` [PATCH v7 4/5] s390/zcrypt: Improve EP11 CPRB domain handling with ASN.1 parsing Harald Freudenberger
2026-07-29 11:01 ` sashiko-bot
2026-07-29 9:53 ` [PATCH v7 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros Harald Freudenberger
2026-07-29 11:16 ` 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=20260729104030.62DF11F000E9@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