linux-sg2042/arch/x86/kernel/fpu
Chang S. Bae b158888402 x86/fpu/xstate: Prevent false-positive warning in __copy_xstate_uabi_buf()
__copy_xstate_to_uabi_buf() copies either from the tasks XSAVE buffer
or from init_fpstate into the ptrace buffer. Dynamic features, like
XTILEDATA, have an all zeroes init state and are not saved in
init_fpstate, which means the corresponding bit is not set in the
xfeatures bitmap of the init_fpstate header.

But __copy_xstate_to_uabi_buf() retrieves addresses for both the tasks
xstate and init_fpstate unconditionally via __raw_xsave_addr().

So if the tasks XSAVE buffer has a dynamic feature set, then the
address retrieval for init_fpstate triggers the warning in
__raw_xsave_addr() which checks the feature bit in the init_fpstate
header.

Remove the address retrieval from init_fpstate for extended features.
They have an all zeroes init state so init_fpstate has zeros for them.
Then zeroing the user buffer for the init state is the same as copying
them from init_fpstate.

Fixes: 2308ee57d9 ("x86/fpu/amx: Enable the AMX feature in 64-bit mode")
Reported-by: Mingwei Zhang <mizhang@google.com>
Link: https://lore.kernel.org/kvm/20230221163655.920289-2-mizhang@google.com/
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Mingwei Zhang <mizhang@google.com>
Link: https://lore.kernel.org/all/20230227210504.18520-2-chang.seok.bae%40intel.com
Cc: stable@vger.kernel.org
2023-03-22 10:59:13 -07:00
..
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
bugs.c x86/fpu: Replace the includes of fpu/internal.h 2021-10-20 15:27:29 +02:00
context.h x86/fpu: Don't set TIF_NEED_FPU_LOAD for PF_IO_WORKER threads 2023-01-25 12:35:15 +01:00
core.c Updates in this cycle: 2023-02-20 18:50:02 -08:00
init.c x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN 2022-11-22 17:13:03 +01:00
internal.h x86/fpu/signal: Prepare for variable sigframe length 2021-10-26 10:18:09 +02:00
legacy.h x86/fpu: Remove .fixup usage 2021-12-11 09:09:48 +01:00
regset.c x86/fpu: Add a pkru argument to copy_uabi_from_kernel_to_xstate(). 2022-11-16 15:03:01 -08:00
signal.c x86/fpu: Take task_struct* in copy_sigframe_from_user_to_xstate() 2022-11-16 15:02:30 -08:00
xstate.c x86/fpu/xstate: Prevent false-positive warning in __copy_xstate_uabi_buf() 2023-03-22 10:59:13 -07:00
xstate.h x86/fpu: Add a pkru argument to copy_uabi_from_kernel_to_xstate(). 2022-11-16 15:03:01 -08:00