Re: [PATCH] i386: handle iret faults better
From: Linus Torvalds
Date: Fri Apr 29 2005 - 11:50:09 EST
On Thu, 28 Apr 2005, Roland McGrath wrote:
> I was never very happy with the special-case check for iret_exc either.
> But for the first crack, I went for the fix that didn't touch other
> infrastructure code.
> The fault.c changes here are really not necessary for the bug fix at all,
> it will never be used there. But to make it a clean infrastructure
> upgrade, I made every caller of fixup_exception consistently pass in the
> complete info it uses for signals in the user-mode case.
I really ended up deciding that we can fix it with a simple one-liner
instead, which actually simplifies and cleans up the code, instead of
adding new special cases.
I just committed the appended, which actually removes one line more than
author Linus Torvalds <torvalds@xxxxxxxxxxxxxxx> Fri, 29 Apr 2005 09:38:44 -0700
committer Linus Torvalds <torvalds@xxxxxxxxxxxxxxx> Fri, 29 Apr 2005 09:38:44 -0700
x86: make traps on 'iret' be debuggable in user space
This makes a trap on the 'iret' that returns us to user space
cause a nice clean SIGSEGV, instead of just a hard (and silent)
That way a debugger can actually try to see what happened, and
we also properly notify everybody who might be interested about
us being gone.
This loses the error code, but tells the debugger what happened
with ILL_BADSTK in the siginfo.
--- k/arch/i386/kernel/entry.S (mode:100644)
+++ l/arch/i386/kernel/entry.S (mode:100644)
@@ -260,11 +260,9 @@ restore_nocheck:
- movl $__USER_DS, %edx
- movl %edx, %ds
- movl %edx, %es
- movl $11,%eax
- call do_exit
+ pushl $0 # no error code
+ pushl $do_iret_error
+ jmp error_code
--- k/arch/i386/kernel/traps.c (mode:100644)
+++ l/arch/i386/kernel/traps.c (mode:100644)
@@ -451,6 +451,7 @@ DO_ERROR(10, SIGSEGV, "invalid TSS", inv
DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
+DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
fastcall void do_general_protection(struct pt_regs * regs, long error_code)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/