x86/fpu: Limit xstate copy size in xstateregs_set()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 23 Jun 2021 12:01:35 +0000 (14:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:17:54 +0000 (16:17 +0200)
[ Upstream commit 07d6688b22e09be465652cf2da0da6bf86154df6 ]

If the count argument is larger than the xstate size, this will happily
copy beyond the end of xstate.

Fixes: 91c3dba7dbc1 ("x86/fpu/xstate: Fix PTRACE frames for XSAVES")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121452.120741557@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/fpu/regset.c

index bc02f5144b958bd8182f284e2cfa6dd5a65384c8..621d249ded0b967bfc90d3af4da564b8e41f0cb6 100644 (file)
@@ -128,7 +128,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
        /*
         * A whole standard-format XSAVE buffer is needed:
         */
-       if ((pos != 0) || (count < fpu_user_xstate_size))
+       if (pos != 0 || count != fpu_user_xstate_size)
                return -EFAULT;
 
        xsave = &fpu->state.xsave;