Skip to content

Commit 8891b17

Browse files
benzearichardweinberger
authored andcommitted
um: avoid copying FP state from init_task
The init_task instance of struct task_struct is statically allocated and does not contain the dynamic area for the userspace FP registers. As such, limit the copy to the valid area of init_task and fill the rest with zero. Note that the FP state is only needed for userspace, and as such it is entirely reasonable for init_task to not contain it. Reported-by: Brian Norris <[email protected]> Closes: https://lore.kernel.org/[email protected] Fixes: 3f17fed ("um: switch to regset API and depend on XSTATE") Signed-off-by: Benjamin Berg <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 5298b7c commit 8891b17

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/um/kernel/process.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,15 @@ void initial_thread_cb(void (*proc)(void *), void *arg)
191191
int arch_dup_task_struct(struct task_struct *dst,
192192
struct task_struct *src)
193193
{
194-
memcpy(dst, src, arch_task_struct_size);
194+
/* init_task is not dynamically sized (missing FPU state) */
195+
if (unlikely(src == &init_task)) {
196+
memcpy(dst, src, sizeof(init_task));
197+
memset((void *)dst + sizeof(init_task), 0,
198+
arch_task_struct_size - sizeof(init_task));
199+
} else {
200+
memcpy(dst, src, arch_task_struct_size);
201+
}
202+
195203
return 0;
196204
}
197205

0 commit comments

Comments
 (0)