Skip to content

x86/fpu: Do not leak fpstate pointer on fork

Rafael Aquini requested to merge raquini/centos-stream-9:bz2120448 into main

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2120448

This patch is a backport of the following upstream commit
commit f0cbc8b3cdf7d1c724155cd9cecffe329bb96119
Author: Thomas Gleixner tglx@linutronix.de
Date: Wed Oct 13 16:55:43 2021 +0200

x86/fpu: Do not leak fpstate pointer on fork  

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  

Signed-off-by: Rafael Aquini aquini@redhat.com

Merge request reports