x86/fpu: Rewrite xfpregs_set()
authorAndy Lutomirski <luto@kernel.org>
Wed, 23 Jun 2021 12:01:39 +0000 (14:01 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 23 Jun 2021 15:49:46 +0000 (17:49 +0200)
commit6164331d15f7d912fb9369245368e9564ea49813
treef0693cf3ecd9cc8589ff975e71515bba756d55c1
parent3a3351126ee8f1f1c86c4c79c60a650c1da89733
x86/fpu: Rewrite xfpregs_set()

xfpregs_set() was incomprehensible.  Almost all of the complexity was due
to trying to support nonsensically sized writes or -EFAULT errors that
would have partially or completely overwritten the destination before
failing.  Nonsensically sized input would only have been possible using
PTRACE_SETREGSET on REGSET_XFP.  Fortunately, it appears (based on Debian
code search results) that no one uses that API at all, let alone with the
wrong sized buffer.  Failed user access can be handled more cleanly by
first copying to kernel memory.

Just rewrite it to require sensible input.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121452.504234607@linutronix.de
arch/x86/kernel/fpu/regset.c