From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751590AbdITDSc (ORCPT ); Tue, 19 Sep 2017 23:18:32 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:32780 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbdITDSb (ORCPT ); Tue, 19 Sep 2017 23:18:31 -0400 X-Google-Smtp-Source: AOwi7QCYse5i2pW3IMMt3Rk3RJ3M6YrJlBKSCOig0SuAdvwty+NmGId0Ldquxyh8W8Tn9d3CvRFY3w== Date: Tue, 19 Sep 2017 20:18:28 -0700 From: Eric Biggers To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Andy Lutomirski , Dave Hansen , Dmitry Vyukov , Fenghua Yu , Ingo Molnar , Kevin Hao , Oleg Nesterov , Wanpeng Li , Yu-cheng Yu , Michael Halcrow , Eric Biggers Subject: Re: [PATCH v2 3/3] x86/fpu: reinitialize FPU registers if restoring FPU state fails Message-ID: <20170920031828.GA537@zzz.localdomain> References: <20170920004434.35308-1-ebiggers3@gmail.com> <20170920004434.35308-4-ebiggers3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170920004434.35308-4-ebiggers3@gmail.com> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 19, 2017 at 05:44:34PM -0700, Eric Biggers wrote: > +/* > + * We should never get here because the fpregs_state stored in 'struct fpu' > + * should always be readable and contain a valid FPU state. However, past bugs > + * have allowed userspace to set reserved bits in the XSAVE area using > + * PTRACE_SETREGSET or sys_rt_sigreturn(). These caused XRSTOR to fail when > + * switching to the task, leaking the FPU registers of the task previously > + * executing on the CPU. Mitigate this class of vulnerability by restoring from > + * the initial state (essentially, zeroing out all the FPU registers) if we > + * can't restore from the task's FPU state. > + */ > +void __handle_bad_fpstate(union fpregs_state *fpstate, u64 mask) > +{ > + WARN_ONCE(1, "Bad FPU state detected, reinitializing FPU registers"); > + ____copy_kernel_to_fpregs(&init_fpstate, mask); > +} Sorry, a small oversight here --- this needs to be exported to modules, since kvm can be built as a module, and kvm uses __copy_kernel_to_fpregs(). Eric