linux-stable/arch/x86
Yu-cheng Yu 98265c17ef x86/fpu/xstate: Preserve supervisor states for the slow path in __fpu__restore_sig()
The signal return code is responsible for taking an XSAVE buffer
present in user memory and loading it into the hardware registers. This
operation only affects user XSAVE state and never affects supervisor
state.

The fast path through this code simply points XRSTOR directly at the
user buffer. However, since user memory is not guaranteed to be always
mapped, this XRSTOR can fail. If it fails, the signal return code falls
back to a slow path which can tolerate page faults.

That slow path copies the xfeatures one by one out of the user buffer
into the task's fpu state area. However, by being in a context where it
can handle page faults, the code can also schedule.

The lazy-fpu-load code would think it has an up-to-date fpstate and
would fail to save the supervisor state when scheduling the task out.
When scheduling back in, it would likely restore stale supervisor state.

To fix that, preserve supervisor state before the slow path.  Modify
copy_user_to_fpregs_zeroing() so that if it fails, fpregs are not zeroed,
and there is no need for fpregs_deactivate() and supervisor states are
preserved.

Move set_thread_flag(TIF_NEED_FPU_LOAD) to the slow path.  Without doing
this, the fast path also needs supervisor states to be saved first.

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200512145444.15483-10-yu-cheng.yu@intel.com
2020-05-16 12:09:11 +02:00
..
boot SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
configs compiler: remove CONFIG_OPTIMIZE_INLINING entirely 2020-04-07 10:43:42 -07:00
crypto crypto: arch/nhpoly1305 - process in explicit 4k chunks 2020-04-30 15:16:59 +10:00
entry x86/unwind/orc: Fix premature unwind stoppage due to IRET frames 2020-04-25 12:22:29 +02:00
events perf/x86/cstate: Add Jasper Lake CPU support 2020-04-22 21:43:12 +02:00
hyperv x86/hyperv: Suspend/resume the VP assist page for hibernation 2020-04-21 10:03:19 +01:00
ia32 Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-03-31 11:04:05 -07:00
include x86/fpu: Introduce copy_supervisor_to_kernel() 2020-05-16 11:24:14 +02:00
kernel x86/fpu/xstate: Preserve supervisor states for the slow path in __fpu__restore_sig() 2020-05-16 12:09:11 +02:00
kvm Merge branch 'akpm' (patches from Andrew) 2020-05-08 08:41:09 -07:00
lib SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
math-emu Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-11-26 10:42:40 -08:00
mm x86/mm/cpa: Flush direct map alias during cpa 2020-04-30 20:14:30 +02:00
net bpf, x86_32: Fix logic error in BPF_LDX zero-extension 2020-04-24 17:23:01 -07:00
oprofile x86: Use pr_warn instead of pr_warning 2019-10-18 15:00:18 +02:00
pci pci-v5.6-changes 2020-01-31 14:48:54 -08:00
platform efi/x86: Don't remap text<->rodata gap read-only for mixed mode 2020-04-14 08:32:17 +02:00
power x86/kernel: Convert to new CPU match macros 2020-03-24 21:28:26 +01:00
purgatory Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-11-26 10:42:40 -08:00
ras
realmode SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
tools .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
um mm/vma: define a default value for VM_DATA_DEFAULT_FLAGS 2020-04-10 15:36:21 -07:00
video
xen xen: branch for v5.7-rc1b 2020-04-10 17:20:06 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kbuild
Kconfig mm/userfaultfd: disable userfaultfd-wp on x86_32 2020-04-21 11:11:55 -07:00
Kconfig.assembler x86: update AS_* macros to binutils >=2.23, supporting ADX and AVX2 2020-04-09 00:12:48 +09:00
Kconfig.cpu x86/cpu: Detect VMX features on Intel, Centaur and Zhaoxin CPUs 2020-01-13 18:02:53 +01:00
Kconfig.debug x86: mm: convert dump_pagetables to use walk_page_range 2020-02-04 03:05:25 +00:00
Makefile x86: probe assembler capabilities via kconfig instead of makefile 2020-04-09 00:01:59 +09:00
Makefile.um
Makefile_32.cpu