Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v2 2/6] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm
Date: Mon, 17 Aug 2026 10:52:43 +0000	[thread overview]
Message-ID: <20260817105244.599641F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817104203.74033-3-freude@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [Medium] Missing memory scrub on stack temporary bounce buffer in `ctr_aes_crypt()`.
- [Medium] Missing memory scrub on stack bounce buffers in `gcm_aes_crypt()`.
--

--- Patch [2]: [PATCH v2 2/6] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm ---
commit 517f415eda900d45f7871a3da2f51b851e06642f
Author: Harald Freudenberger <freude@linux.ibm.com>

s390/crypto: Fix missing scrub of temp buffers with PAES algorithm

This patch explicitly scrubs the stack bounce buffer used for partial block
processing in ctr_paes_do_crypt(). It also updates __xts_2keys_prep_param()
to scrub the entire pcc_param structure rather than just the key field,
preventing inadvertent exposure of sensitive cryptographic material.

> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> index ccc7da106c3a0..d075b0241f1f5 100644
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
> @@ -1044,6 +1044,7 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
>  	}
>  
>  out:
> +	memzero_explicit(buf, sizeof(buf));

[Severity: Medium]
This is a pre-existing issue, but does ctr_aes_crypt() in
arch/s390/crypto/aes_s390.c have the same missing scrub on its temporary
bounce buffer?

Like the PAES algorithm fixed here, intermediate cryptographic data
appears to be left on the kernel stack when an AES-CTR operation
processes a final partial block that is not a multiple of AES_BLOCK_SIZE:

arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
    ...
	if (nbytes) {
		memset(buf, 0, AES_BLOCK_SIZE);
		memcpy(buf, walk.src.virt.addr, nbytes);
		cpacf_kmctr(sctx->fc, sctx->key, buf, buf,
			    AES_BLOCK_SIZE, walk.iv);
		memcpy(walk.dst.virt.addr, buf, nbytes);
		crypto_inc(walk.iv, AES_BLOCK_SIZE);
		ret = skcipher_walk_done(&walk, 0);
	}

	return ret;
}

>  	pr_debug("rc=%d\n", rc);
>  	return rc;
>  }
> @@ -1377,7 +1378,7 @@ static inline int __xts_2keys_prep_param(struct s390_pxts_ctx *ctx,
>  		memcpy(param->init, pcc_param.xts, 16);
>  	}
>  
> -	memzero_explicit(pcc_param.key, sizeof(pcc_param.key));
> +	memzero_explicit(&pcc_param, sizeof(pcc_param));

[Severity: Medium]
This is also a pre-existing issue, but does gcm_aes_crypt() in
arch/s390/crypto/aes_s390.c also need its stack bounce buffers scrubbed?

It explicitly scrubs the param structure, but seems to omit scrubbing
gw_in and gw_out. This leaves intermediate cryptographic data on the stack
when an AES-GCM operation with scattered or unaligned data uses the internal
bounce buffers:

arch/s390/crypto/aes_s390.c:gcm_aes_crypt() {
    ...
	struct gcm_sg_walk gw_in, gw_out;
    ...
	memzero_explicit(&param, sizeof(param));
	return ret;
}

>  	return rc;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817104203.74033-1-freude@linux.ibm.com?part=2

  reply	other threads:[~2026-08-17 10:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 10:41 [PATCH v2 0/6] Fixes and rework for paes_s390 Harald Freudenberger
2026-08-17 10:41 ` [PATCH v2 1/6] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-17 11:01   ` sashiko-bot
2026-08-17 10:41 ` [PATCH v2 2/6] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-17 10:52   ` sashiko-bot [this message]
2026-08-17 10:42 ` [PATCH v2 3/6] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-17 10:50   ` sashiko-bot
2026-08-17 10:42 ` [PATCH v2 4/6] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-17 10:57   ` sashiko-bot
2026-08-17 10:42 ` [PATCH v2 5/6] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-17 10:58   ` sashiko-bot
2026-08-17 10:42 ` [PATCH v2 6/6] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-17 10:56   ` 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=20260817105244.599641F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@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