Skip to content

Commit

Permalink
uprobes: Send SIGILL if handle_trampoline() fails
Browse files Browse the repository at this point in the history
1. It doesn't make sense to continue if handle_trampoline()
   fails, change handle_swbp() to always return after this call.

2. Turn pr_warn() into uprobe_warn(), and change
   handle_trampoline() to send SIGILL on failure. It is pointless to
   return to user mode with the corrupted instruction_pointer() which
   we can't restore.

Tested-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Anton Arapov <arapov@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20150721134008.GA4745@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Oleg Nesterov authored and Ingo Molnar committed Jul 31, 2015
1 parent 2bb5e84 commit 0b5256c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,19 +1770,19 @@ handle_uretprobe_chain(struct return_instance *ri, struct pt_regs *regs)
up_read(&uprobe->register_rwsem);
}

static bool handle_trampoline(struct pt_regs *regs)
static void handle_trampoline(struct pt_regs *regs)
{
struct uprobe_task *utask;
struct return_instance *ri;
bool chained;

utask = current->utask;
if (!utask)
return false;
goto sigill;

ri = utask->return_instances;
if (!ri)
return false;
goto sigill;

/*
* TODO: we should throw out return_instance's invalidated by
Expand All @@ -1804,8 +1804,12 @@ static bool handle_trampoline(struct pt_regs *regs)
}

utask->return_instances = ri;
return;

sigill:
uprobe_warn(current, "handle uretprobe, sending SIGILL.");
force_sig_info(SIGILL, SEND_SIG_FORCED, current);

return true;
}

bool __weak arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs)
Expand All @@ -1824,13 +1828,8 @@ static void handle_swbp(struct pt_regs *regs)
int uninitialized_var(is_swbp);

bp_vaddr = uprobe_get_swbp_addr(regs);
if (bp_vaddr == get_trampoline_vaddr()) {
if (handle_trampoline(regs))
return;

pr_warn("uprobe: unable to handle uretprobe pid/tgid=%d/%d\n",
current->pid, current->tgid);
}
if (bp_vaddr == get_trampoline_vaddr())
return handle_trampoline(regs);

uprobe = find_active_uprobe(bp_vaddr, &is_swbp);
if (!uprobe) {
Expand Down

0 comments on commit 0b5256c

Please sign in to comment.