[PATCH 19/20] lib/crypto: riscv/aes-ctr: Migrate optimized code into library

Karl Mehltretter kmehltretter at gmail.com
Mon Sep 21 22:44:01 PDT 2026


On Sun, 20 Sep 2026 22:09:05 -0700 Eric Biggers <ebiggers at kernel.org> wrote:
> -// void aes_ctr32_crypt_zvkned_zvkb(const struct crypto_aes_ctx *key,
> -//				    const u8 *in, u8 *out, size_t len,
> -//				    u8 iv[16]);
> +// void aes_ctr32_crypt_zvkned_zvkb(u8 *dst, const u8 *src, u32 len, u8 iv[16],
> +//				    const struct aes_enckey *key);
>  SYM_FUNC_START(aes_ctr32_crypt_zvkned_zvkb)

isn't this a sign extension problem on rv64? The psABI sign-extends
32-bit args, so for len >= 2G a2 comes in as 0xffffffff8xxxxxxx, and
the asm uses it as a 64-bit length as is.

That would run off the end of both buffers.

Nothing passes that much in one call today, but aes_ctr_arch() only
chunks down to 0xfffffff0 and aes_ctr() takes a size_t, so it is
allowed. The old prototype was size_t and the caller zero-extended.

Thanks,
Karl



More information about the linux-riscv mailing list