Andy, Thomas Gleixner <t...@linutronix.de> writes: > In historic kernels si_addr was simply set to regs->ip and the uprobe > muck changed that in commit b02ef20a9fba08 ("uprobes/x86: Fix the wrong > ->si_addr when xol triggers a trap") > > If the probed insn triggers a trap, ->si_addr = regs->ip is technically > correct, but this is not what the signal handler wants; we need to pass > the address of the probed insn, not the address of xol slot. > > Now that I filled my own blanks, I think that I can come up with a > halfways useful comment.
That's what I came up with (delta patch) Thanks, tglx 8<--------------- --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -205,6 +205,16 @@ static void do_error_trap(struct pt_regs } } +/* + * Posix requires to provide the address of the faulting instruction for + * SIGILL (#UD) and SIGFPE (#DE) in the si_addr member of siginfo_t. + * + * This address is usually regs->ip, but when an uprobe moved the code out + * of line then regs->ip points to the XOL code which would confuse + * anything which analyzes the fault address vs. the unmodified binary. If + * a trap happened in XOL code then uprobe maps regs->ip back to the + * original instruction address. + */ static __always_inline void __user *error_get_trap_addr(struct pt_regs *regs) { return (void __user *)uprobe_get_trap_addr(regs);