[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aDPYRUTYVGii2NYd@gondor.apana.org.au>
Date: Mon, 26 May 2025 10:56:05 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Eric Biggers <ebiggers@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
linux-pm@...r.kernel.org, Borislav Petkov <bp@...en8.de>,
Ayush Jain <Ayush.Jain3@....com>, Ard Biesheuvel <ardb@...nel.org>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH] x86/fpu: Fix irq_fpu_usable() to return false during CPU
onlining
On Wed, May 21, 2025 at 05:39:41PM +0200, Thomas Gleixner wrote:
> On Sun, May 18 2025 at 12:32, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@...gle.com>
> >
> > irq_fpu_usable() incorrectly returned true before the FPU is
> > initialized. The x86 CPU onlining code can call sha256() to checksum
> > AMD microcode images, before the FPU is initialized. Since sha256()
> > recently gained a kernel-mode FPU optimized code path, a crash occurred
> > in kernel_fpu_begin_mask() during hotplug CPU onlining.
> >
> > (The crash did not occur during boot-time CPU onlining, since the
> > optimized sha256() code is not enabled until subsys_initcalls run.)
> >
> > Fix this by making irq_fpu_usable() return false before fpu__init_cpu()
> > has run. To do this without adding any additional overhead to
> > irq_fpu_usable(), replace the existing per-CPU bool in_kernel_fpu with
> > kernel_fpu_allowed which tracks both initialization and usage rather
> > than just usage. The initial state is false; FPU initialization sets it
> > to true; kernel-mode FPU sections toggle it to false and then back to
> > true; and CPU offlining restores it to the initial state of false.
> >
> > Fixes: 11d7956d526f ("crypto: x86/sha256 - implement library instead of shash")
> > Reported-by: Ayush Jain <Ayush.Jain3@....com>
> > Closes: https://lore.kernel.org/r/20250516112217.GBaCcf6Yoc6LkIIryP@fat_crate.local
> > Signed-off-by: Eric Biggers <ebiggers@...gle.com>
>
> Reviewed-by: Thomas Gleixner <tglx@...utronix.de>
Since this patch is holding up my pull request, I will be applying
it to cryptodev.
Thanks,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists