From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v6 2/9] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm
Date: Fri, 21 Aug 2026 08:58:38 +0000 [thread overview]
Message-ID: <20260821085838.72BF31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821084648.23222-3-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing explicit scrub of local stack buffer `buf` in `ctr_aes_crypt()` (standard AES algorithm).
- [High] Missing explicit scrub of temp buffers in `gcm_sg_walk` structures and AES keys in `gcm_aes_crypt()`.
--
--- Patch [2]: [PATCH v6 2/9] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm ---
commit 0f77835bffb943e6b87472b41b755be562bb23c4
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/crypto: Fix missing scrub of temp buffers with PAES algorithm
This commit explicitly zeroizes temporary stack buffers used for partial
block processing in the paes algorithm. It also updates the scrubbing
logic in the xts parameter preparation function to clear the entire
parameter block rather than just the key field.
> 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: High]
This isn't a bug introduced by this patch, but while you are fixing the missing
scrub of buf here, there appears to be an identical pre-existing issue in the
standard aes implementation.
In arch/s390/crypto/aes_s390.c:ctr_aes_crypt(), the local stack buffer buf
is populated with cryptographic data when processing a final partial block,
but it returns without scrubbing the buffer:
ret = skcipher_walk_done(&walk, 0);
}
return ret;
}
Since this path is reachable by unprivileged users invoking the ctr(aes)
algorithm with unaligned lengths, does ctr_aes_crypt() need a similar
memzero_explicit() call before returning to avoid leaving sensitive data on
the kernel stack?
[Severity: High]
This is another pre-existing issue in the same subsystem, but looking at
gcm_aes_crypt() in arch/s390/crypto/aes_s390.c, there are error paths that
bypass the existing memzero_explicit() cleanup completely:
return -ENOMEM;
if (gcm_out_walk_done(&gw_out, n) != n)
return -ENOMEM;
If these error paths are taken when processing fragmented input data, does this
leave the aes key and hash subkey on the kernel stack?
Additionally, the normal exit path cleans the param block but doesn't appear
to clean the buf fields in the gcm_sg_walk structures (gw_in and gw_out):
memzero_explicit(¶m, sizeof(param));
return ret;
}
Should these temporary buffers and early return paths also be scrubbed?
> 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));
> return rc;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821084648.23222-1-freude@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-08-21 8:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 8:46 [PATCH v6 0/9] Fixes and rework for paes_s390 and phmac_s390 Harald Freudenberger
2026-08-21 8:46 ` [PATCH v6 1/9] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-21 8:57 ` sashiko-bot
2026-08-21 8:46 ` [PATCH v6 2/9] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-21 8:58 ` sashiko-bot [this message]
2026-08-21 9:04 ` Harald Freudenberger
2026-08-21 8:46 ` [PATCH v6 3/9] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-21 8:56 ` sashiko-bot
2026-08-21 9:01 ` Harald Freudenberger
2026-08-21 8:46 ` [PATCH v6 4/9] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-21 8:52 ` sashiko-bot
2026-08-21 8:46 ` [PATCH v6 5/9] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-21 10:08 ` sashiko-bot
2026-08-21 8:46 ` [PATCH v6 6/9] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-21 9:00 ` sashiko-bot
2026-08-21 8:46 ` [PATCH v6 7/9] s390/crypto: Fix wrong return code to engine in asynch callbacks Harald Freudenberger
2026-08-21 8:54 ` sashiko-bot
2026-08-21 8:46 ` [PATCH v6 8/9] s390/crypto: Map EBUSY to EIO when key conversion fails repeatedly Harald Freudenberger
2026-08-21 8:59 ` sashiko-bot
2026-08-21 8:46 ` [PATCH v6 9/9] s390/crypto: Enable CONTEXT_ANALYSIS Harald Freudenberger
2026-08-21 8:55 ` 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=20260821085838.72BF31F000E9@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