From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbbGaN7Q (ORCPT ); Fri, 31 Jul 2015 09:59:16 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57333 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752305AbbGaN7G (ORCPT ); Fri, 31 Jul 2015 09:59:06 -0400 Date: Fri, 31 Jul 2015 06:58:29 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, panand@redhat.com, tglx@linutronix.de, oleg@redhat.com, peterz@infradead.org, hpa@zytor.com, arapov@gmail.com, luto@amacapital.net, srikar@linux.vnet.ibm.com, torvalds@linux-foundation.org Reply-To: oleg@redhat.com, peterz@infradead.org, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org, panand@redhat.com, tglx@linutronix.de, torvalds@linux-foundation.org, arapov@gmail.com, srikar@linux.vnet.ibm.com, luto@amacapital.net In-Reply-To: <20150721134008.GA4745@redhat.com> References: <20150721134008.GA4745@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] uprobes: Send SIGILL if handle_trampoline() fails Git-Commit-ID: 0b5256c7f173258b19d98364adb57f707dda22f3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0b5256c7f173258b19d98364adb57f707dda22f3 Gitweb: http://git.kernel.org/tip/0b5256c7f173258b19d98364adb57f707dda22f3 Author: Oleg Nesterov AuthorDate: Tue, 21 Jul 2015 15:40:08 +0200 Committer: Ingo Molnar CommitDate: Fri, 31 Jul 2015 10:38:03 +0200 uprobes: Send SIGILL if handle_trampoline() fails 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 Signed-off-by: Oleg Nesterov Acked-by: Srikar Dronamraju Acked-by: Anton Arapov Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20150721134008.GA4745@redhat.com Signed-off-by: Ingo Molnar --- kernel/events/uprobes.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index d8c702f..eabdc21 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1770,7 +1770,7 @@ 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; @@ -1778,11 +1778,11 @@ static bool handle_trampoline(struct pt_regs *regs) 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 @@ -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) @@ -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) {