diff options
| author | Yu-cheng Yu <yu-cheng.yu@intel.com> | 2016-11-17 12:11:35 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2016-11-21 04:38:35 -0500 |
| commit | b22cbe404a9cc3c7949e380fa1861e31934c8978 (patch) | |
| tree | b88f02a3b34c3d138a96b9f6174ab66e643c3af0 /arch/x86/kernel | |
| parent | ed68d7e9b9cfb64f3045ffbcb108df03c09a0f98 (diff) | |
x86/fpu: Fix invalid FPU ptrace state after execve()
Robert O'Callahan reported that after an execve PTRACE_GETREGSET
NT_X86_XSTATE continues to return the pre-exec register values
until the exec'ed task modifies FPU state.
The test code is at:
https://bugzilla.redhat.com/attachment.cgi?id=1164286.
What is happening is fpu__clear() does not properly clear fpstate.
Fix it by doing just that.
Reported-by: Robert O'Callahan <robert@ocallahan.org>
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Cc: <stable@vger.kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1479402695-6553-1-git-send-email-yu-cheng.yu@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
| -rw-r--r-- | arch/x86/kernel/fpu/core.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 47004010ad5d..ebb4e95fbd74 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c | |||
| @@ -521,14 +521,14 @@ void fpu__clear(struct fpu *fpu) | |||
| 521 | { | 521 | { |
| 522 | WARN_ON_FPU(fpu != ¤t->thread.fpu); /* Almost certainly an anomaly */ | 522 | WARN_ON_FPU(fpu != ¤t->thread.fpu); /* Almost certainly an anomaly */ |
| 523 | 523 | ||
| 524 | if (!use_eager_fpu() || !static_cpu_has(X86_FEATURE_FPU)) { | 524 | fpu__drop(fpu); |
| 525 | /* FPU state will be reallocated lazily at the first use. */ | 525 | |
| 526 | fpu__drop(fpu); | 526 | /* |
| 527 | } else { | 527 | * Make sure fpstate is cleared and initialized. |
| 528 | if (!fpu->fpstate_active) { | 528 | */ |
| 529 | fpu__activate_curr(fpu); | 529 | if (static_cpu_has(X86_FEATURE_FPU)) { |
| 530 | user_fpu_begin(); | 530 | fpu__activate_curr(fpu); |
| 531 | } | 531 | user_fpu_begin(); |
| 532 | copy_init_fpstate_to_fpregs(); | 532 | copy_init_fpstate_to_fpregs(); |
| 533 | } | 533 | } |
| 534 | } | 534 | } |
