x86/fpu/xstate: Clear xstate header in copy_xstate_to_uabi_buf() again
authorThomas Gleixner <tglx@linutronix.de>
Thu, 24 Jun 2021 15:09:18 +0000 (17:09 +0200)
committerBorislav Petkov <bp@suse.de>
Thu, 24 Jun 2021 15:19:51 +0000 (17:19 +0200)
The change which made copy_xstate_to_uabi_buf() usable for
[x]fpregs_get() removed the zeroing of the header which means the
header, which is copied to user space later, contains except for the
xfeatures member, random stack content.

Add the memset() back to zero it before usage.

Fixes: eb6f51723f03 ("x86/fpu: Make copy_xstate_to_kernel() usable for [x]fpregs_get()")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/875yy3wb8h.ffs@nanos.tec.linutronix.de
arch/x86/kernel/fpu/xstate.c

index 21a10a66c4e4509c80c5ca80e24df86a0840d867..c8def1b7f8fbad81b43ea5c34d1a46cd1b46c085 100644 (file)
@@ -982,6 +982,7 @@ void copy_xstate_to_uabi_buf(struct membuf to, struct task_struct *tsk,
        unsigned int zerofrom;
        int i;
 
+       memset(&header, 0, sizeof(header));
        header.xfeatures = xsave->header.xfeatures;
 
        /* Mask out the feature bits depending on copy mode */