From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Christian Borntraeger" <borntraeger@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v7 3/9] s390/crypto: Fix use of mutex in atomic context in PAES
Date: Mon, 31 Aug 2026 09:19:22 +0000 [thread overview]
Message-ID: <20260831091923.895B61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831083838.3703-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 standard AES CTR implementation (`ctr-aes-s390`) calls `mutex_trylock()` and `mutex_unlock()` within its encryption routine `ctr_aes_crypt()`. This is unsafe because synchronous skcipher algorithms can be invoked from atomic/interrupt contexts (such as softirqs processing IPsec traffic), leading to locking violations and potential crashes.
--
commit 54e6d65629d9606907edef94511d7b4e99ed2398
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/crypto: Fix use of mutex in atomic context in PAES
This commit fixes a locking violation in the PAES CTR implementation by
replacing a mutex with a binary semaphore. Mutexes are not safe to use in
atomic or interrupt contexts, where crypto operations are often invoked. It
also restructures the PAES CTR code to remove conditional locking.
> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> index d075b0241f1f5..10d1c56a049d6 100644
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
> @@ -45,7 +45,7 @@ module_param_named(clrkey, pkey_clrkey_allowed, bool, 0444);
> MODULE_PARM_DESC(clrkey, "Allow clear key material (default N)");
>
> static u8 *ctrblk;
> -static DEFINE_MUTEX(ctrblk_lock);
> +static DEFINE_SEMAPHORE(ctrblk_sem, 1);
[Severity: High]
This is a pre-existing issue, but while this patch successfully fixes the
mutex usage in the PAES implementation, does the standard AES CTR
implementation in arch/s390/crypto/aes_s390.c suffer from the exact same
problem?
Looking at ctr_aes_crypt() in arch/s390/crypto/aes_s390.c, it appears to
still use a mutex:
arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
...
locked = mutex_trylock(&ctrblk_lock);
...
}
and later:
arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
...
if (locked)
mutex_unlock(&ctrblk_lock);
...
}
Since the AES CTR skcipher algorithm is registered as synchronous, it can be
called from softirq context, such as when processing IPsec traffic. Calling
mutex operations from softirq context violates kernel locking rules and can
trigger lockdep warnings or panics on PREEMPT_RT kernels.
Does the AES CTR implementation need a similar fix to use a binary semaphore
instead of a mutex?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831083838.3703-1-freude@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-08-31 9:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 8:38 [PATCH v7 0/9] Fixes and rework for paes_s390 and phmac_s390 Harald Freudenberger
2026-08-31 8:38 ` [PATCH v7 1/9] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-31 8:55 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 2/9] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-31 9:10 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 3/9] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-31 9:19 ` sashiko-bot [this message]
2026-08-31 8:38 ` [PATCH v7 4/9] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-31 9:32 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 5/9] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-31 9:45 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 6/9] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-31 9:58 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 7/9] s390/crypto: Fix wrong return code to engine in asynch callbacks Harald Freudenberger
2026-08-31 10:04 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 8/9] s390/crypto: Map EBUSY to EIO when key conversion fails repeatedly Harald Freudenberger
2026-08-31 10:10 ` sashiko-bot
2026-08-31 8:38 ` [PATCH v7 9/9] s390/crypto: Enable CONTEXT_ANALYSIS Harald Freudenberger
2026-08-31 10:11 ` 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=20260831091923.895B61F000E9@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