Re: [PATCH] lib/crypto: aescfb: Don't disable IRQs during AES block encryption

From: Ard Biesheuvel

Date: Tue Mar 31 2026 - 02:48:21 EST




On Tue, 31 Mar 2026, at 04:44, Eric Biggers wrote:
> aes_encrypt() now uses AES instructions when available instead of always
> using table-based code. AES instructions are constant-time and don't
> benefit from disabling IRQs as a constant-time hardening measure.
>
> In fact, on two architectures (arm and riscv) disabling IRQs is
> counterproductive because it prevents the AES instructions from being
> used. (See the may_use_simd() implementation on those architectures.)
>
> Therefore, let's remove the IRQ disabling/enabling and leave the choice
> of constant-time hardening measures to the AES library code.
>
> Note that currently the arm table-based AES code (which runs on arm
> kernels that don't have ARMv8 CE) disables IRQs, while the generic
> table-based AES code does not. So this does technically regress in
> constant-time hardening when that generic code is used. But as
> discussed in commit a22fd0e3c495 ("lib/crypto: aes: Introduce improved
> AES library") I think just leaving IRQs enabled is the right choice.
> Disabling them is slow and can cause problems, and AES instructions
> (which modern CPUs have) solve the problem in a much better way anyway.
>
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> ---
> lib/crypto/aescfb.c | 25 +++----------------------
> 1 file changed, 3 insertions(+), 22 deletions(-)
>

Reviewed-by: Ard Biesheuvel <ardb@xxxxxxxxxx>