From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v7 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros
Date: Wed, 29 Jul 2026 11:16:18 +0000 [thread overview]
Message-ID: <20260729111618.DF31B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729095318.184141-6-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing bounds check on `offset1` and `count1` in `zcrypt_msgtype6_receive` when `count2` is present, leading to an arbitrary kernel memory disclosure to userspace.
--
--- Patch [5]: [PATCH v7 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros ---
commit d39d55b2525dc84382b638f22d1bbcec3350871f
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/zcrypt: Pad trailing CCA or EP11 message with zeros
This commit pads the gap between the user space copied message and the
message buffer length with zeros. This prevents up to 3 bytes of
uninitialized kernel memory from being exposed to the crypto card firmware.
> diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c
> index 59e182d1bddf9..0269c92a84bd4 100644
> --- a/drivers/s390/crypto/zcrypt_msgtype6.c
> +++ b/drivers/s390/crypto/zcrypt_msgtype6.c
[ ... ]
[Severity: High]
This is a pre-existing issue, but while looking at this file, does this code
in zcrypt_msgtype6_receive() lack a bounds check for offset1 and count1 when
count2 is present?
drivers/s390/crypto/zcrypt_msgtype6.c:zcrypt_msgtype6_receive() {
...
if (t86r->fmt2.count2)
len = t86r->fmt2.offset2 + t86r->fmt2.count2;
else
len = t86r->fmt2.offset1 + t86r->fmt2.count1;
if (len > reply->bufsize || len > msg->bufsize ||
len != reply->len) {
...
}
If a faulty or compromised crypto card firmware returns a response where
count2 != 0 but offset1 + count1 is maliciously large, len is calculated
entirely from offset2 + count2. This skips bounds checking for offset1 +
count1 against the buffer bounds.
Later, in convert_type86_xcrb(), the unvalidated offset1 and count1 are used
to copy kernel memory to userspace:
drivers/s390/crypto/zcrypt_msgtype6.c:convert_type86_xcrb() {
...
if (z_copy_to_user(userspace, xcrb->reply_control_blk_addr,
data + msg->fmt2.offset1, msg->fmt2.count1))
return -EFAULT;
...
}
Could this lead to an out-of-bounds read that leaks uninitialized slab
memory or unrelated kernel memory to userspace?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729095318.184141-1-freude@linux.ibm.com?part=5
prev parent reply other threads:[~2026-07-29 11:16 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
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 [this message]
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=20260729111618.DF31B1F000E9@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.