]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/fpu: Do not leak fpstate pointer on fork
authorThomas Gleixner <tglx@linutronix.de>
Wed, 13 Oct 2021 14:55:43 +0000 (16:55 +0200)
committerBorislav Petkov <bp@suse.de>
Thu, 21 Oct 2021 07:32:41 +0000 (09:32 +0200)
If fork fails early then the copied task struct would carry the fpstate
pointer of the parent task.

Not a problem right now, but later when dynamically allocated buffers
are available, keeping the pointer might result in freeing the
parent's buffer. Set it to NULL which prevents that. If fork reaches
clone_thread(), the pointer will be correctly set to the new task
context.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211013145322.817101108@linutronix.de
arch/x86/kernel/process.c

index 5cd82082353e9687015762e40f7b67bf749cf91f..c74c7e889e9d96a1f8ef85a537b8c60ab5266e9f 100644 (file)
@@ -87,6 +87,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 #ifdef CONFIG_VM86
        dst->thread.vm86 = NULL;
 #endif
+       /* Drop the copied pointer to current's fpstate */
+       dst->thread.fpu.fpstate = NULL;
        return 0;
 }