Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752063AbcJAUuI (ORCPT ); Sat, 1 Oct 2016 16:50:08 -0400 Received: from shelob.surriel.com ([74.92.59.67]:50131 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbcJAUuG (ORCPT ); Sat, 1 Oct 2016 16:50:06 -0400 From: riel@redhat.com To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@linutronix.de, pbonzini@redhat.com, mingo@redhat.com, luto@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, bp@suse.de Subject: [PATCH RFC 5/5] x86,fpu: kinda sorta fix up signal path Date: Sat, 1 Oct 2016 16:31:35 -0400 Message-Id: <1475353895-22175-6-git-send-email-riel@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475353895-22175-1-git-send-email-riel@redhat.com> References: <1475353895-22175-1-git-send-email-riel@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1500 Lines: 43 From: Rik van Riel Need to ensure that the FPU save code and the lazy restore code do not use invalid kernel or floating point register state and copy it over to the other location. I am pretty sure this is incomplete. Signed-off-by: Rik van Riel --- arch/x86/kernel/fpu/core.c | 1 + arch/x86/kernel/fpu/signal.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 537eb65b6ae6..fa59cc741fa5 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -314,6 +314,7 @@ void fpu__activate_curr(struct fpu *fpu) trace_x86_fpu_activate_state(fpu); /* Safe to do for the current task: */ fpu->fpstate_active = 1; + fpu->last_cpu = -1; } } EXPORT_SYMBOL_GPL(fpu__activate_curr); diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index a184c210efba..89f882983da7 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -171,6 +171,10 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) (struct _fpstate_32 __user *) buf) ? -1 : 1; if (fpregs_active() || using_compacted_format()) { + /* Compacted format, but the FP state is not loaded yet. */ + if (unlikely(!fpu_lazy_skip_restore(&tsk->thread.fpu))) + copy_kernel_to_fpregs(&tsk->thread.fpu.state); + /* Save the live register state to the user directly. */ if (copy_fpregs_to_sigframe(buf_fx)) return -1; -- 2.7.4