[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181221162905.GB7797@kroah.com>
Date: Fri, 21 Dec 2018 17:29:05 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: Borislav Petkov <bp@...en8.de>,
Jari Ruusu <jariruusu@...rs.sourceforge.net>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
"Jason A. Donenfeld" <Jason@...c4.com>,
kvm ML <kvm@...r.kernel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Kr?má? <rkrcmar@...hat.com>,
Rik van Riel <riel@...riel.com>, x86-ml <x86@...nel.org>
Subject: Re: [PATCH v4.9 STABLE] x86/fpu: Disable bottom halves while loading
FPU registers
On Fri, Dec 21, 2018 at 05:23:38PM +0100, Sebastian Andrzej Siewior wrote:
> The sequence
>
> fpu->initialized = 1; /* step A */
> preempt_disable(); /* step B */
> fpu__restore(fpu);
> preempt_enable();
>
> in __fpu__restore_sig() is racy in regard to a context switch.
>
> For 32bit frames, __fpu__restore_sig() prepares the FPU state within
> fpu->state. To ensure that a context switch (switch_fpu_prepare() in
> particular) does not modify fpu->state it uses fpu__drop() which sets
> fpu->initialized to 0.
>
> After fpu->initialized is cleared, the CPU's FPU state is not saved
> to fpu->state during a context switch. The new state is loaded via
> fpu__restore(). It gets loaded into fpu->state from userland and
> ensured it is sane. fpu->initialized is then set to 1 in order to avoid
> fpu__initialize() doing anything (overwrite the new state) which is part
> of fpu__restore().
>
> A context switch between step A and B above would save CPU's current FPU
> registers to fpu->state and overwrite the newly prepared state. This
> looks like a tiny race window but the Kernel Test Robot reported this
> back in 2016 while we had lazy FPU support. Borislav Petkov made the
> link between that report and another patch that has been posted. Since
> the removal of the lazy FPU support, this race goes unnoticed because
> the warning has been removed.
>
> Disable bottom halves around the restore sequence to avoid the race. BH
> need to be disabled because BH is allowed to run (even with preemption
> disabled) and might invoke kernel_fpu_begin() by doing IPsec.
>
> [ bp: massage commit message a bit. ]
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> Signed-off-by: Borislav Petkov <bp@...e.de>
> Acked-by: Ingo Molnar <mingo@...nel.org>
> Acked-by: Thomas Gleixner <tglx@...utronix.de>
> Cc: Andy Lutomirski <luto@...nel.org>
> Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Cc: "Jason A. Donenfeld" <Jason@...c4.com>
> Cc: kvm ML <kvm@...r.kernel.org>
> Cc: Paolo Bonzini <pbonzini@...hat.com>
> Cc: Radim Krčmář <rkrcmar@...hat.com>
> Cc: Rik van Riel <riel@...riel.com>
> Cc: stable@...r.kernel.org
> Cc: x86-ml <x86@...nel.org>
> Link: http://lkml.kernel.org/r/20181120102635.ddv3fvavxajjlfqk@linutronix.de
> Link: https://lkml.kernel.org/r/20160226074940.GA28911@pd.tnic
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> arch/x86/kernel/fpu/signal.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
What is the git commit id of this patch upstream?
thanks,
greg k-h
Powered by blists - more mailing lists