All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Freudenberger <freude@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-s390@vger.kernel.org,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH v9 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros
Date: Thu, 30 Jul 2026 09:44:30 +0200	[thread overview]
Message-ID: <4cb782c8746e264adcc03993b3c8ea40@linux.ibm.com> (raw)
In-Reply-To: <20260729170739.C0FF11F000E9@smtp.kernel.org>

On 2026-07-29 19:07, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider:
> 
> Pre-existing issues:
> - [High] This problem wasn't introduced by this patch, but an integer
> overflow and incomplete bounds checking in hardware response parsing
> allows a massive out-of-bounds kernel memory leak to userspace.
> --
> 
> --- Patch [5]: [PATCH v9 5/5] s390/zcrypt: Pad trailing CCA or EP11
> message with zeros ---
> commit 0141bfa352999fc87f7b7c58c7c727f991c4b416
> Author: Harald Freudenberger <freude@linux.ibm.com>
> 
> s390/zcrypt: Pad trailing CCA or EP11 message with zeros
> 
> This patch fixes an information leak to the crypto card firmware. It 
> zeroes
> out the gap between the user space copied message and the message 
> buffer
> length sent to the CCA or EP11 message processing.
> 
>> diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c 
>> b/drivers/s390/crypto/zcrypt_msgtype6.c
>> index da7580933c6f2..4a60540b07003 100644
>> --- a/drivers/s390/crypto/zcrypt_msgtype6.c
>> +++ b/drivers/s390/crypto/zcrypt_msgtype6.c
> 
> [ ... ]
> 
> [Severity: High]
> This is a pre-existing issue, but I noticed an integer overflow and
> incomplete bounds checking in hardware response parsing that could 
> allow an
> out-of-bounds kernel memory leak to userspace.
> 
> In zcrypt_msgtype6_receive():
> 
>         if (t86r->fmt2.count2)
>             len = t86r->fmt2.offset2 + t86r->fmt2.count2;
>         else
>             len = t86r->fmt2.offset1 + t86r->fmt2.count1;
> 
> If a compromised or malicious crypto device firmware returns a response 
> where
> offset1 + count1 overflows 32-bit arithmetic, it might bypass the 
> buffer
> size check. Alternatively, if count2 is non-zero, the bounds check in
> zcrypt_msgtype6_receive() only validates offset2 + count2 and 
> completely
> ignores offset1 + count1.
> 
> Later in convert_type86_xcrb():
> 
>     if (z_copy_to_user(userspace, xcrb->reply_control_blk_addr,
>                data + msg->fmt2.offset1, msg->fmt2.count1))
>         return -EFAULT;
> 
> Since the bounds check can pass under those conditions, could offset1 
> be
> used as an unvalidated offset into kernel memory here, resulting in
> z_copy_to_user() copying out-of-bounds kernel memory into the 
> user-provided
> buffer?

maybe valid, will be covered with another patch series (bugzilla 220850 
opened)

      reply	other threads:[~2026-07-30  7:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 15:44 [PATCH v9 0/5] Improve code in zcrypt msg type 6 handling Harald Freudenberger
2026-07-29 15:44 ` [PATCH v9 1/5] s390/zcrypt: Fix CPRB memory allocation in zcrypt misc code Harald Freudenberger
2026-07-29 16:02   ` sashiko-bot
2026-07-29 15:44 ` [PATCH v9 2/5] s390/zcrypt: Improve CCA CPRB length and overflow checks Harald Freudenberger
2026-07-29 16:19   ` sashiko-bot
2026-07-30 13:13     ` Harald Freudenberger
2026-07-29 15:44 ` [PATCH v9 3/5] s390/zcrypt: Improve EP11 " Harald Freudenberger
2026-07-29 16:35   ` sashiko-bot
2026-07-30  8:58     ` Harald Freudenberger
2026-07-29 15:44 ` [PATCH v9 4/5] s390/zcrypt: Improve EP11 CPRB domain handling with ASN.1 parsing Harald Freudenberger
2026-07-29 16:46   ` sashiko-bot
2026-07-30 11:55     ` Harald Freudenberger
2026-07-29 15:44 ` [PATCH v9 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros Harald Freudenberger
2026-07-29 17:07   ` sashiko-bot
2026-07-30  7:44     ` Harald Freudenberger [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=4cb782c8746e264adcc03993b3c8ea40@linux.ibm.com \
    --to=freude@linux.ibm.com \
    --cc=agordeev@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.