lkml.org 
[lkml]   [2020]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [patch V4 part 3 13/29] x86/traps: Prepare for using DEFINE_IDTENTRY
Date
Andy,

Thomas Gleixner <tglx@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);
\
 
 \ /
  Last update: 2020-05-15 15:44    [W:0.097 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site