]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/fpu: Avoid copying dynamic FP state from init_task in arch_dup_task_struct()
authorBenjamin Berg <benjamin.berg@intel.com>
Wed, 26 Feb 2025 13:31:36 +0000 (14:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:57 +0000 (14:31 +0200)
commit3047aba1425384eab816b57add9bc807ccf39002
tree9e6c051162f5445d7b03dcd1dc0023ac3b1d24f9
parentdc6e7db76a35553e1f9a0b624eea29fcf59b04c1
x86/fpu: Avoid copying dynamic FP state from init_task in arch_dup_task_struct()

[ Upstream commit 5d3b81d4d8520efe888536b6906dc10fd1a228a8 ]

The init_task instance of struct task_struct is statically allocated and
may not contain the full FP state for userspace. As such, limit the copy
to the valid area of both init_task and 'dst' and ensure all memory is
initialized.

Note that the FP state is only needed for userspace, and as such it is
entirely reasonable for init_task to not contain parts of it.

Fixes: 5aaeb5c01c5b ("x86/fpu, sched: Introduce CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT and use it on x86")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20250226133136.816901-1-benjamin@sipsolutions.net
----

v2:
- Fix code if arch_task_struct_size < sizeof(init_task) by using
  memcpy_and_pad.

Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/process.c