linux-stable/arch
Brian Geffon 64e0b5894c x86/fpu: Correct pkru/xstate inconsistency
When eagerly switching PKRU in switch_fpu_finish() it checks that
current is not a kernel thread as kernel threads will never use PKRU.
It's possible that this_cpu_read_stable() on current_task
(ie. get_current()) is returning an old cached value. To resolve this
reference next_p directly rather than relying on current.

As written it's possible when switching from a kernel thread to a
userspace thread to observe a cached PF_KTHREAD flag and never restore
the PKRU. And as a result this issue only occurs when switching
from a kernel thread to a userspace thread, switching from a non kernel
thread works perfectly fine because all that is considered in that
situation are the flags from some other non kernel task and the next fpu
is passed in to switch_fpu_finish().

This behavior only exists between 5.2 and 5.13 when it was fixed by a
rewrite decoupling PKRU from xstate, in:
  commit 954436989c ("x86/fpu: Remove PKRU handling from switch_fpu_finish()")

Unfortunately backporting the fix from 5.13 is probably not realistic as
it's part of a 60+ patch series which rewrites most of the PKRU handling.

Fixes: 0cecca9d03 ("x86/fpu: Eager switch PKRU state")
Signed-off-by: Brian Geffon <bgeffon@google.com>
Signed-off-by: Willis Kung <williskung@google.com>
Tested-by: Willis Kung <williskung@google.com>
Cc: <stable@vger.kernel.org> # v5.4.x
Cc: <stable@vger.kernel.org> # v5.10.x
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-02 11:41:03 +01:00
..
alpha alpha: Declare virt_to_phys and virt_to_bus parameter as pointer to volatile 2021-09-30 10:09:26 +02:00
arc ARC: export clear_user_page() for modules 2021-09-22 12:26:45 +02:00
arm ARM: OMAP2+: adjust the location of put_device() call in omapdss_init_of 2022-02-23 12:00:00 +01:00
arm64 arm64: dts: meson-g12: drop BL32 region from SEI510/SEI610 2022-02-23 12:00:01 +01:00
c6x
csky perf: Protect perf_guest_cbs with RCU 2022-01-20 09:19:18 +01:00
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-02-17 10:35:18 +01:00
hexagon hexagon: export raw I/O routines for modules 2021-11-26 10:47:21 +01:00
ia64 Revert "ia64: kprobes: Use generic kretprobe trampoline handler" 2022-01-27 09:19:56 +01:00
m68k m68k: set a default value for MEMORY_RESERVE 2021-11-17 09:48:46 +01:00
microblaze
mips MIPS: Octeon: Fix build errors using clang 2022-01-27 09:19:48 +01:00
nds32 perf: Protect perf_guest_cbs with RCU 2022-01-20 09:19:18 +01:00
nios2 nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST 2021-11-02 19:46:14 +01:00
openrisc openrisc: don't printk() unconditionally 2021-09-22 12:26:24 +02:00
parisc parisc/unaligned: Fix ldw() and stw() unalignment handlers 2022-03-02 11:41:01 +01:00
powerpc powerpc/lib/sstep: fix 'ptesync' build error 2022-02-23 11:59:58 +01:00
riscv riscv: fix build with binutils 2.38 2022-02-16 12:52:49 +01:00
s390 s390/hypfs: include z/VM guests with access control group set 2022-02-01 17:24:33 +01:00
sh sh: define __BIG_ENDIAN for math-emu 2021-11-26 10:47:17 +01:00
sparc sparc64: fix pci_iounmap() when CONFIG_PCI is not set 2021-10-09 14:39:49 +02:00
um um: registers: Rename function names to avoid conflicts and build problems 2022-01-27 09:19:45 +01:00
unicore32
x86 x86/fpu: Correct pkru/xstate inconsistency 2022-03-02 11:41:03 +01:00
xtensa xtensa: xtfpga: Try software restart before simulating CPU reset 2021-10-27 09:54:25 +02:00
.gitignore
Kconfig Revert: "ring-buffer: Remove HAVE_64BIT_ALIGNED_ACCESS" 2020-12-30 11:51:47 +01:00