lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87zgsyg0eg.ffs@tglx>
Date:   Mon, 30 Aug 2021 22:09:27 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Borislav Petkov <bp@...en8.de>
Cc:     LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
        Al Viro <viro@...iv.linux.org.uk>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [patch 01/10] x86/fpu/signal: Clarify exception handling in
 restore_fpregs_from_user()

On Mon, Aug 30 2021 at 21:33, Borislav Petkov wrote:
> On Mon, Aug 30, 2021 at 06:27:22PM +0200, Thomas Gleixner wrote:
>> FPU restore from a signal frame can trigger various exceptions. The
>> exceptions are caught with an exception table entry. The handler of this
>> entry sets the error return value to the negated exception number.
>> 
>> 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.
>> 
>> Check the error code for -X86_TRAP_PF instead of checking it for -EFAULT to
>> make it clear how that works.
>
> I guess you wanna fixup the comment over XSTATE_OP() too and perhaps
> mention ex_handler_fault() explicitly so that one can make her/his way
> around the code and pinpoint quickly where it sticks that exception
> number into rAX.

Something like the below?

Thanks,

        tglx
---
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -88,7 +88,11 @@ static inline void fpstate_init_soft(str
 #endif
 extern void save_fpregs_to_fpstate(struct fpu *fpu);
 
-/* Returns 0 or the negated trap number, which results in -EFAULT for #PF */
+/*
+ * Returns 0 on success or the negated trap number when the operation
+ * raises an exception (The exception fixup function ex_handler_fault()
+ * stores the trap number in EAX).
+ */
 #define user_insn(insn, output, input...)				\
 ({									\
 	int err;							\
@@ -199,7 +203,8 @@ static inline void fxsave(struct fxregs_
 
 /*
  * After this @err contains 0 on success or the negated trap number when
- * the operation raises an exception. For faults this results in -EFAULT.
+ * the operation raises an exception (The exception fixup function
+ * ex_handler_fault() stores the trap number in EAX).
  */
 #define XSTATE_OP(op, st, lmask, hmask, err)				\
 	asm volatile("1:" op "\n\t"					\

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ