From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH v5 3/8] s390/crypto: Fix use of mutex in atomic context in PAES
Date: Thu, 20 Aug 2026 14:29:19 +0000 [thread overview]
Message-ID: <20260820142920.104011F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260820141957.19091-4-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch correctly replaces an unsafe `mutex_trylock()` with a binary semaphore in the `paes_s390` PAES CTR implementation, because mutexes cannot be safely locked in atomic or interrupt context. However, it fails to apply the exact same fix to the closely related standard AES CTR implementation in `aes_s390.c`. The function `ctr_aes_crypt()` still uses `mutex_trylock(&ctrblk_lock)` on its fast path, which is unsafe when called from softirq/atomic context.
--
--- Patch [3]: [PATCH v5 3/8] s390/crypto: Fix use of mutex in atomic context in PAES ---
commit a2afbae94320906011d9357378185a56c441bdd2
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/crypto: Fix use of mutex in atomic context in PAES
The PAES CTR implementation used a mutex to lock one page of exclusive
memory for fast CTR processing. Unfortunately a mutex is not save to
use in atomic or interrupt context. So use a binary semaphore instead
which is save to use in such environments.
> 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 I noticed the standard AES CTR
implementation in arch/s390/crypto/aes_s390.c seems to suffer from the
exact same problem.
Looking at ctr_aes_crypt() in aes_s390.c, it still uses mutex_trylock()
on its fast path:
arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
...
if (unlikely(!sctx->fc))
return fallback_skcipher_crypt(sctx, req, 0);
locked = mutex_trylock(&ctrblk_lock);
ret = skcipher_walk_virt(&walk, req, false);
...
}
Since mutexes cannot be safely locked in atomic or interrupt context, and
network IPsec/MACsec could execute packet decryption in softirq context,
does the standard AES implementation need this identical fix as well?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260820141957.19091-1-freude@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-08-20 14:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 14:19 [PATCH v5 0/8] Fixes and rework for paes_s390 and phmac_s390 Harald Freudenberger
2026-08-20 14:19 ` [PATCH v5 1/8] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-20 14:30 ` sashiko-bot
2026-08-20 14:19 ` [PATCH v5 2/8] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-20 14:29 ` sashiko-bot
2026-08-20 14:19 ` [PATCH v5 3/8] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-20 14:29 ` sashiko-bot [this message]
2026-08-20 14:19 ` [PATCH v5 4/8] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-20 14:26 ` sashiko-bot
2026-08-20 14:19 ` [PATCH v5 5/8] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-20 14:31 ` sashiko-bot
2026-08-20 14:19 ` [PATCH v5 6/8] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-20 14:35 ` sashiko-bot
2026-08-20 14:19 ` [PATCH v5 7/8] s390/crypto: Fix wrong return code to engine in asynch callbacks Harald Freudenberger
2026-08-20 14:26 ` sashiko-bot
2026-08-20 14:19 ` [PATCH v5 8/8] s390/crypto: Map EBUSY to EIO when key conversion fails repeatedly Harald Freudenberger
2026-08-20 14:32 ` 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=20260820142920.104011F00A3A@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