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 v11 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks
Date: Mon, 03 Aug 2026 09:04:26 +0000 [thread overview]
Message-ID: <20260803090427.81AF31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803083339.212885-3-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Out-of-bounds read into uninitialized padding due to relaxed bounds check.
Pre-existing issues:
- [High] Missing minimum size validation for EP11 requests allows uninitialized memory access.
--
--- Patch [2]: [PATCH v11 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks ---
commit 91475dced80fa0f4ff3795e01d4bba627b9d0bfe
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/zcrypt: Improve CCA CPRB length and overflow checks
This commit improves length and overflow validations for CCA CPRB structures.
It updates calculations to use size_t, adds U32_MAX boundary checks, and
enforces minimum control block size requirements.
> diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c
> index 40f72cdf284d3..3e19e79d747cf 100644
> --- a/drivers/s390/crypto/zcrypt_msgtype6.c
> +++ b/drivers/s390/crypto/zcrypt_msgtype6.c
[ ... ]
> @@ -404,8 +394,8 @@ static int xcrb_msg_to_type6cprb_msgx(bool userspace, struct ap_message *ap_msg,
> xcrb->request_control_blk_addr,
> xcrb->request_control_blk_length))
> return -EFAULT;
> - if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) >
> - xcrb->request_control_blk_length)
> + /* copy subfunction code into AP msg type 6 function code field */
> + if (msg->cprbx.cprb_len > req_cblen - sizeof(msg->hdr.function_code))
> return -EINVAL;
> function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len;
> memcpy(msg->hdr.function_code, function_code,
[Severity: High]
Does this change allow an out-of-bounds read into uninitialized padding?
The bounds check was relaxed from checking against
request_control_blk_length to checking against the 4-byte aligned req_cblen.
If a user supplies an unaligned xcrb->request_control_blk_length (e.g., 37)
and sets msg->cprbx.cprb_len to point into the uninitialized padding
(e.g., 38), it appears up to 2 bytes of uninitialized kernel heap memory can
be read into msg->hdr.function_code and subsequently sent to the
cryptographic hardware.
[Severity: High]
This is a pre-existing issue, but could we apply similar minimum size
validation to xcrb_msg_to_type6_ep11cprb_msgx() for EP11 requests?
When a user calls the zcrypt ioctl for an EP11 request with an undersized
xcrb->req_len (e.g., 0):
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)) {
...
}
User-supplied data is copied using the user-controlled length without
verifying it meets the minimum required size for the struct fields that
are subsequently accessed.
This allows uninitialized heap memory in ap_msg->msg to dictate control flow
and be sent to the cryptographic hardware when reading fields like
msg->pld_lenfmt or msg->cprbx.flags.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803083339.212885-1-freude@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-08-03 9:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 8:33 [PATCH v11 0/5] Improve code in zcrypt msg type 6 handling Harald Freudenberger
2026-08-03 8:33 ` [PATCH v11 1/5] s390/zcrypt: Fix CPRB memory allocation in zcrypt misc code Harald Freudenberger
2026-08-03 8:42 ` sashiko-bot
2026-08-03 8:33 ` [PATCH v11 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks Harald Freudenberger
2026-08-03 9:04 ` sashiko-bot [this message]
2026-08-03 9:10 ` Harald Freudenberger
2026-08-03 8:33 ` [PATCH v11 3/5] s390/zcrypt: Improve EP11 " Harald Freudenberger
2026-08-03 8:50 ` sashiko-bot
2026-08-03 9:09 ` Harald Freudenberger
2026-08-03 15:03 ` Holger Dengler
2026-08-03 8:33 ` [PATCH v11 4/5] s390/zcrypt: Improve EP11 CPRB domain handling with ASN.1 parsing Harald Freudenberger
2026-08-03 8:42 ` sashiko-bot
2026-08-03 15:03 ` Holger Dengler
2026-08-03 8:33 ` [PATCH v11 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros Harald Freudenberger
2026-08-03 8:49 ` sashiko-bot
2026-08-03 9:08 ` Harald Freudenberger
2026-08-04 7:30 ` [PATCH v11 0/5] Improve code in zcrypt msg type 6 handling Vasily Gorbik
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=20260803090427.81AF31F000E9@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 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.