From: Eric Biggers <ebiggers@kernel.org>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH 19/20] lib/crypto: riscv/aes-ctr: Migrate optimized code into library
Date: Mon, 21 Sep 2026 22:52:24 -0700 [thread overview]
Message-ID: <20260922055224.GC14616@sol> (raw)
In-Reply-To: <20260922054401.19194-1-kmehltretter@gmail.com>
On Tue, Sep 22, 2026 at 07:44:01AM +0200, Karl Mehltretter wrote:
> On Sun, 20 Sep 2026 22:09:05 -0700 Eric Biggers <ebiggers@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.
Yes, Sashiko found this too. I'll probably make the assembly function
continue to take size_t.
- Eric
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH 19/20] lib/crypto: riscv/aes-ctr: Migrate optimized code into library
Date: Mon, 21 Sep 2026 22:52:24 -0700 [thread overview]
Message-ID: <20260922055224.GC14616@sol> (raw)
In-Reply-To: <20260922054401.19194-1-kmehltretter@gmail.com>
On Tue, Sep 22, 2026 at 07:44:01AM +0200, Karl Mehltretter wrote:
> On Sun, 20 Sep 2026 22:09:05 -0700 Eric Biggers <ebiggers@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.
Yes, Sashiko found this too. I'll probably make the assembly function
continue to take size_t.
- Eric
next prev parent reply other threads:[~2026-09-22 5:52 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 5:08 [PATCH 00/20] Migrate x86 and RISC-V accelerated AES modes into library Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 01/20] crypto: aes - Fix undesired override of some optimized AES modes Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 02/20] lib/crypto: aes-xctr: Pass counter by value to aes_xctr_arch() Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-23 8:42 ` Thomas Huth
2026-09-23 8:42 ` Thomas Huth
2026-09-21 5:08 ` [PATCH 03/20] lib/crypto: x86/aes: Clean up aes-aesni.S in preparation for AES modes Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 04/20] lib/crypto: x86/aes-ecb: Add AES-NI optimization Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 05/20] lib/crypto: x86/aes-cbc: " Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 06/20] lib/crypto: x86/aes-ctr: " Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 07/20] lib/crypto: x86/aes-xts: " Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 08/20] crypto: x86/aes-ecb - Remove superseded ECB skcipher Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 09/20] crypto: x86/aes-cbc - Remove superseded CBC skciphers Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-22 4:15 ` Karl Mehltretter
2026-09-22 5:11 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 10/20] crypto: x86/aes-ctr - Remove superseded CTR skcipher Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 11/20] crypto: x86/aes-xts - Remove superseded XTS skcipher Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 12/20] lib/crypto: x86/aes-ctr: Migrate AVX-optimized code into library Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:08 ` [PATCH 13/20] lib/crypto: x86/aes-xts: " Eric Biggers
2026-09-21 5:08 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 14/20] crypto: x86/aes - Drop superseded 32-bit build support Eric Biggers
2026-09-21 5:09 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 15/20] lib/crypto: riscv/aes: Copy aes-macros.S to library Eric Biggers
2026-09-21 5:09 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 16/20] lib/crypto: riscv/aes: Pass key struct to assembly code Eric Biggers
2026-09-21 5:09 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 17/20] lib/crypto: riscv/aes-ecb: Migrate optimized code into library Eric Biggers
2026-09-21 5:09 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 18/20] lib/crypto: riscv/aes-cbc: " Eric Biggers
2026-09-21 5:09 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 19/20] lib/crypto: riscv/aes-ctr: " Eric Biggers
2026-09-21 5:09 ` Eric Biggers
2026-09-22 5:44 ` Karl Mehltretter
2026-09-22 5:44 ` Karl Mehltretter
2026-09-22 5:52 ` Eric Biggers [this message]
2026-09-22 5:52 ` Eric Biggers
2026-09-21 5:09 ` [PATCH 20/20] lib/crypto: riscv/aes-xts: " Eric Biggers
2026-09-21 5:09 ` Eric Biggers
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=20260922055224.GC14616@sol \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=kmehltretter@gmail.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.