Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753928AbbBTKTb (ORCPT ); Fri, 20 Feb 2015 05:19:31 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:36999 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbbBTKTa (ORCPT ); Fri, 20 Feb 2015 05:19:30 -0500 Date: Fri, 20 Feb 2015 11:19:25 +0100 From: Ingo Molnar To: Petr Mladek Cc: Masami Hiramatsu , "David S. Miller" , Anil S Keshavamurthy , Ananth NMavinakayanahalli , Frederic Weisbecker , Steven Rostedt , Jiri Kosina , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] kprobes/x86: Check for invalid ftrace location in __recover_probed_insn() Message-ID: <20150220101925.GB25076@gmail.com> References: <20150218212205.GA26334@gmail.com> <1424427402-11795-1-git-send-email-pmladek@suse.cz> <1424427402-11795-3-git-send-email-pmladek@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424427402-11795-3-git-send-email-pmladek@suse.cz> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1621 Lines: 45 * Petr Mladek wrote: > __recover_probed_insn() should always be called from an address where > an instructions starts. The check for ftrace_location() might help to > discover a potential inconsistency. Something goes terribly wrong when > an address inside the ftrace location is checked. Let's BUG() in this case. > > Suggested-by: Masami Hiramatsu > Signed-off-by: Petr Mladek > Acked-by: Masami Hiramatsu > --- > arch/x86/kernel/kprobes/core.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c > index 2f464b56766a..124577dcf768 100644 > --- a/arch/x86/kernel/kprobes/core.c > +++ b/arch/x86/kernel/kprobes/core.c > @@ -228,6 +228,12 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) > kp = get_kprobe((void *)addr); > faddr = ftrace_location(addr); > /* > + * Addresses inside the ftrace location are refused by > + * arch_check_ftrace_location(). Something went terribly wrong > + * if such an address is checked here. > + */ > + BUG_ON(faddr && faddr != addr); Crashing the system with a BUG_ON() makes users very sad. Please use a construct like: if (WARN_ON(faddr && faddr != addr)) return gently; I've picked up your first patch. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/