x86/fpu/signal: Move xstate clearing out of copy_fpregs_to_sigframe()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 8 Sep 2021 13:29:30 +0000 (15:29 +0200)
committerBorislav Petkov <bp@suse.de>
Tue, 14 Sep 2021 19:10:03 +0000 (21:10 +0200)
commitfcfb7163329ce832aafef31f26345ef5e8642a17
treede788ae378a3a9a4df8b876ed82201f5784b4fab
parent4164a482a5d92c29eaf53d01755103f6bbce38f2
x86/fpu/signal: Move xstate clearing out of copy_fpregs_to_sigframe()

When the direct saving of the FPU registers to the user space sigframe
fails, copy_fpregs_to_sigframe() attempts to clear the user buffer.

The most likely reason for such a fail is a page fault. As
copy_fpregs_to_sigframe() is invoked with pagefaults disabled the chance
that __clear_user() succeeds is minuscule.

Move the clearing out into the caller which replaces the
fault_in_pages_writeable() in that error handling path.

The return value confusion will be cleaned up separately.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210908132525.679356300@linutronix.de
arch/x86/kernel/fpu/signal.c