linux-stable/arch
Andrei Vagin 8bd3eee772 x86/fpu: Stop relying on userspace for info to fault in xsave buffer
commit d877550eaf upstream.

Before this change, the expected size of the user space buffer was
taken from fx_sw->xstate_size. fx_sw->xstate_size can be changed
from user-space, so it is possible construct a sigreturn frame where:

 * fx_sw->xstate_size is smaller than the size required by valid bits in
   fx_sw->xfeatures.
 * user-space unmaps parts of the sigrame fpu buffer so that not all of
   the buffer required by xrstor is accessible.

In this case, xrstor tries to restore and accesses the unmapped area
which results in a fault. But fault_in_readable succeeds because buf +
fx_sw->xstate_size is within the still mapped area, so it goes back and
tries xrstor again. It will spin in this loop forever.

Instead, fault in the maximum size which can be touched by XRSTOR (taken
from fpstate->user_size).

[ dhansen: tweak subject / changelog ]

Fixes: fcb3635f50 ("x86/fpu/signal: Handle #PF in the direct restore path")
Reported-by: Konstantin Bogomolov <bogomolov@google.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrei Vagin <avagin@google.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc:stable@vger.kernel.org
Link: https://lore.kernel.org/all/20240130063603.3392627-1-avagin%40google.com
Link: https://lore.kernel.org/all/20240130063603.3392627-1-avagin%40google.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-01 13:21:43 +01:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:22:03 +02:00
arc ARC: fix spare error 2024-01-25 14:52:30 -08:00
arm ARM: dts: imx23/28: Fix the DMA controller node name 2024-02-23 08:54:44 +01:00
arm64 arm64: Subscribe Microsoft Azure Cobalt 100 to ARM Neoverse N2 errata 2024-02-23 08:55:14 +01:00
csky arch: consolidate arch_irq_work_raise prototypes 2024-02-23 08:54:39 +01:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-01 08:27:21 +01:00
hexagon hexagon: Fix function name in die() 2023-02-01 08:27:20 +01:00
ia64 memblock: allow to specify flags with memblock_add_node() 2023-12-20 15:17:33 +01:00
m68k memblock: allow to specify flags with memblock_add_node() 2023-12-20 15:17:33 +01:00
microblaze exit: Add and use make_task_dead. 2023-02-01 08:27:20 +01:00
mips MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler 2024-02-23 08:55:02 +01:00
nds32 exit: Add and use make_task_dead. 2023-02-01 08:27:20 +01:00
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:59:14 +02:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-11 23:00:37 +09:00
parisc parisc/firmware: Fix F-extend for PDC addresses 2024-02-23 08:54:24 +01:00
powerpc powerpc/64: Set task pt_regs->link to the LR value on scv entry 2024-02-23 08:55:08 +01:00
riscv arch: consolidate arch_irq_work_raise prototypes 2024-02-23 08:54:39 +01:00
s390 KVM: s390: fix setting of fpc register 2024-02-23 08:54:40 +01:00
sh sh: bios: Revive earlyprintk support 2023-11-20 11:08:23 +01:00
sparc sparc32: fix a braino in fault handling in csum_and_copy_..._user() 2023-11-08 17:26:42 +01:00
um um: time-travel: fix time corruption 2024-02-23 08:54:50 +01:00
x86 x86/fpu: Stop relying on userspace for info to fault in xsave buffer 2024-03-01 13:21:43 +01:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-06 13:18:14 +02:00
.gitignore
Kconfig scs: add CONFIG_MMU dependency for vfree_atomic() 2024-02-23 08:55:02 +01:00