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

From: Eric Biggers

Date: Thu Apr 02 2026 - 19:21:49 EST


On Mon, Mar 30, 2026 at 07:44:30PM -0700, 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/aesgcm.c | 25 +++----------------------
> 1 file changed, 3 insertions(+), 22 deletions(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric