Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The standard AES CTR implementation uses `mutex_trylock()` and `mutex_unlock()` in a context that may be atomic, which violates core kernel locking rules.
--
--- Patch [3]: [PATCH v4 3/7] s390/crypto: Fix use of mutex in atomic context in PAES ---
commit d6ba4976a19245fd83ba5c797399a6bd57d986bb
Author: Harald Freudenberger <[email protected]>
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. This commit replaces the mutex with a
binary semaphore, since a mutex is not safe to use in atomic or interrupt
context.
> 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
[ ... ]
> @@ -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 does the standard AES implementation in
arch/s390/crypto/aes_s390.c suffer from this exact same problem?
Looking at ctr_aes_crypt() in arch/s390/crypto/aes_s390.c:
locked = mutex_trylock(&ctrblk_lock);
ret = skcipher_walk_virt(&walk, req, false);
while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) {
...
}
if (locked)
mutex_unlock(&ctrblk_lock);
Network traffic processing (e.g., IPsec) executes SKCIPHER operations from
a softirq context. Unlocking a mutex in an interrupt context triggers a
kernel panic or BUG on PREEMPT_RT kernels, and lockdep warnings on
standard kernels.
Since this patch successfully fixes the issue for PAES, should a similar
fix be applied to arch/s390/crypto/aes_s390.c?
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.