]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
x86/fpu/signal: Clarify exception handling in restore_fpregs_from_user()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 8 Sep 2021 13:29:26 +0000 (15:29 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:55:48 +0000 (11:55 +0200)
commitff83121a967dc8ef3769216eaa1e13a7e0c4cfca
tree417f864be458fba2616296781b077fe89ce7e36d
parentedaee3417ff1d61897a4b81a09adcd3c4a60f783
x86/fpu/signal: Clarify exception handling in restore_fpregs_from_user()

BugLink: https://bugs.launchpad.net/bugs/1967750
FPU restore from a signal frame can trigger various exceptions. The
exceptions are caught with an exception table entry. The handler of this
entry stores the trap number in EAX. The FPU specific fixup negates that
trap number to convert it into an negative error code.

Any other exception than #PF is fatal and recovery is not possible. This
relies on the fact that the #PF exception number is the same as EFAULT, but
that's not really obvious.

Remove the negation from the exception fixup as it really has no value and
check for X86_TRAP_PF at the call site.

There is still confusion due to the return code conversion for the error
case which 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.506192488@linutronix.de
(cherry picked from commit 4339d0c63c2d5bea1fe6de4091ee2fe9eeea09a7)
Acked-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
arch/x86/include/asm/fpu/internal.h
arch/x86/kernel/fpu/signal.c