From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH v3 3/6] s390/crypto: Fix use of mutex in atomic context in PAES
Date: Mon, 17 Aug 2026 14:26:09 +0000 [thread overview]
Message-ID: <20260817142609.AC4FE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817141654.77940-4-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Temporary stack buffer `buf` containing plaintext and keystream is not zeroed before returning from `ctr_aes_crypt`.
- [High] The identical `mutex_trylock()` in atomic context bug remains unfixed in `arch/s390/crypto/aes_s390.c` for standard AES CTR mode.
--
--- Patch [3]: [PATCH v3 3/6] s390/crypto: Fix use of mutex in atomic context in PAES ---
commit a7d845af838256909450e5168e0a9dc3dda32e5a
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/crypto: Fix use of mutex in atomic context in PAES
This commit replaces a mutex with a binary semaphore in the PAES CTR
implementation to allow fast CTR processing. This change avoids issues
when operating in atomic or interrupt contexts where mutexes are unsafe.
Cc: stable@vger.kernel.org # 6.16+
> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> index d075b0241f1f5..e8bbfc376ebb1 100644
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
[ ... ]
> @@ -971,7 +972,7 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
> if (rc)
> goto out;
>
> - locked = mutex_trylock(&ctrblk_lock);
> + locked = down_trylock(&ctrblk_sem) == 0;
[Severity: High]
This is a pre-existing issue, but does arch/s390/crypto/aes_s390.c also
need this exact same fix?
It looks like ctr_aes_crypt() in arch/s390/crypto/aes_s390.c still uses
mutex_trylock() in atomic context:
arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
...
locked = mutex_trylock(&ctrblk_lock);
...
}
Since ctr_aes_crypt() implements standard AES CTR as part of the skcipher
API, it is frequently reached via network processing from softirq context.
Could this trigger lockdep splats or fail on RT kernels if not updated to
use a binary semaphore?
[ ... ]
> @@ -1016,7 +1017,7 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
> }
> }
> if (locked)
> - mutex_unlock(&ctrblk_lock);
> + up(&ctrblk_sem);
>
> /* final block may be < AES_BLOCK_SIZE, copy only nbytes */
> if (nbytes) {
[Severity: Critical]
This isn't a bug introduced by this patch, but while looking at the stack
buffer handling here, does arch/s390/crypto/aes_s390.c need to clear its
temporary buffer before returning?
In ctr_aes_crypt(), there is a temporary stack buffer buf that isn't
zeroed before the function returns:
arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
...
if (nbytes) {
...
ret = skcipher_walk_done(&walk, 0);
}
return ret;
}
During partial block processing, buf receives decrypted plaintext and the
remainder contains the raw AES CTR keystream. Since it isn't cleared explicitly,
could this leave cryptographic material on the kernel stack and expose
sensitive data to other components via uninitialized stack exposure vectors?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260817141654.77940-1-freude@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-08-17 14:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 14:16 [PATCH v3 0/6] Fixes and rework for paes_s390 Harald Freudenberger
2026-08-17 14:16 ` [PATCH v3 1/6] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-17 14:22 ` sashiko-bot
2026-08-17 14:16 ` [PATCH v3 2/6] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-17 14:23 ` sashiko-bot
2026-08-17 14:16 ` [PATCH v3 3/6] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-17 14:26 ` sashiko-bot [this message]
2026-08-17 14:16 ` [PATCH v3 4/6] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-17 14:22 ` sashiko-bot
2026-08-17 14:16 ` [PATCH v3 5/6] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-17 14:27 ` sashiko-bot
2026-08-17 14:16 ` [PATCH v3 6/6] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-17 14:35 ` 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=20260817142609.AC4FE1F000E9@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