[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250426180326.GA1184@sol.localdomain>
Date: Sat, 26 Apr 2025 11:03:26 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arch@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mips@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-riscv@...ts.infradead.org, sparclinux@...r.kernel.org,
linux-s390@...r.kernel.org, x86@...nel.org, ardb@...nel.org,
Jason@...c4.com, torvalds@...ux-foundation.org
Subject: Re: [PATCH 11/13] crypto: x86/sha256 - implement library instead of
shash
On Sat, Apr 26, 2025 at 06:50:43PM +0800, Herbert Xu wrote:
> Eric Biggers <ebiggers@...nel.org> wrote:
> >
> > +void sha256_blocks_arch(u32 state[SHA256_STATE_WORDS],
> > + const u8 *data, size_t nblocks)
> > +{
> > + if (static_branch_likely(&have_sha256_x86) && crypto_simd_usable()) {
> > + kernel_fpu_begin();
> > + static_call(sha256_blocks_x86)(state, data, nblocks);
> > + kernel_fpu_end();
> > + } else {
> > + sha256_blocks_generic(state, data, nblocks);
> > + }
>
> Why did you restore the SIMD fallback path? Please provide a real
> use-case for doing SHA2 in a hardirq or I'll just remove it again.
The SHA-256 library functions currently work in any context, and this patch
series preserves that behavior. Changing that would be a separate change.
But also as I've explained before, for the library API the performance benefit
of removing the crypto_simd_usable() doesn't seem to be worth the footgun that
would be introduced. Your position is, effectively, that if someone calls one
of the sha256*() functions from a hardirq, we should sometimes corrupt a random
task's FPU registers. That's a really bad bug that is very difficult to
root-cause. My position is that we should make it just work as expected.
Yes, no one *should* be doing SHA-256 in a hardirq. But I don't think that
means we should corrupt a random task's FPU registers if someone doesn't follow
best practices, when we can easily make the API just work as expected.
- Eric
Powered by blists - more mailing lists