All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Freudenberger <freude@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	linux-s390@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH v11 5/5] s390/zcrypt: Pad trailing CCA or EP11 message with zeros
Date: Mon, 03 Aug 2026 11:08:36 +0200	[thread overview]
Message-ID: <68406f4891093fa940b04e51ec4dbe35@linux.ibm.com> (raw)
In-Reply-To: <20260803084925.617881F000E9@smtp.kernel.org>

On 2026-08-03 10:49, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider:
> 
> Pre-existing issues:
> - [Medium] The function `zcrypt_type6_crt_key()` leaves up to 7 bytes
> of padding uninitialized before sending the key token to the crypto
> card, leaking kernel memory.
> --
> 
> --- Patch [5]: [PATCH v11 5/5] s390/zcrypt: Pad trailing CCA or EP11
> message with zeros ---
> commit a6bb8fce2d346e386b1306d838ac36f1853d13f8
> Author: Harald Freudenberger <freude@linux.ibm.com>
> 
> s390/zcrypt: Pad trailing CCA or EP11 message with zeros
> 
> This commit pads the gap between the message copied from userspace and
> the message buffer sent to the CCA/EP11 hardware. This prevents
> uninitialized kernel memory from being forwarded to the crypto card.
> 
>> diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c 
>> b/drivers/s390/crypto/zcrypt_msgtype6.c
>> index e79e68b4dd41d..3df1d676de5d8 100644
>> --- a/drivers/s390/crypto/zcrypt_msgtype6.c
>> +++ b/drivers/s390/crypto/zcrypt_msgtype6.c
>> @@ -398,6 +398,10 @@ 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;
>> +	/* pad tail with 0 up to req_cblen */
>> +	if (xcrb->request_control_blk_length < req_cblen)
>> +		memset(msg->userdata + xcrb->request_control_blk_length,
>> +		       0, req_cblen - xcrb->request_control_blk_length);
> 
> [Severity: Medium]
> This is a pre-existing issue, but while reviewing this fix for 
> uninitialized
> memory leaks, I noticed a similar issue in zcrypt_type6_crt_key() where
> pad_len bytes appear to be left uninitialized:
> 
> drivers/s390/crypto/zcrypt_cca_key.h:zcrypt_type6_crt_key() {
>     ...
>     memset(key, 0, sizeof(*key));
>     ...
>     if (copy_from_user(key->key_parts, crt->np_prime, long_len) ||
>         copy_from_user(key->key_parts + long_len,
>                        crt->nq_prime, short_len) ||
>         copy_from_user(key->key_parts + long_len + short_len,
>                        crt->bp_key, long_len) ||
>         copy_from_user(key->key_parts + 2 * long_len + short_len,
>                        crt->bq_key, short_len) ||
>         copy_from_user(key->key_parts + 2 * long_len + 2 * short_len,
>                        crt->u_mult_inv, long_len))
>         return -EFAULT;
>     memset(key->key_parts + 3 * long_len + 2 * short_len + pad_len,
>            0xff, crt->inputdatalength);
>     ...
> }
> 
> Because sizeof(*key) doesn't include the flexible array member 
> key_parts[],
> the memory inside key_parts is uninitialized before the copies.
> 
> Does the final memset() skip over pad_len bytes by adding it to the 
> offset,
> leaving those padding bytes uninitialized before being sent to the 
> firmware?

Different issue - will be addressed with another patch.

  reply	other threads:[~2026-08-03  9:08 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
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 [this message]
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=68406f4891093fa940b04e51ec4dbe35@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.