Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756309AbbBDBPv (ORCPT ); Tue, 3 Feb 2015 20:15:51 -0500 Received: from mail7.hitachi.co.jp ([133.145.228.42]:43733 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934082AbbBDBPJ (ORCPT ); Tue, 3 Feb 2015 20:15:09 -0500 Message-ID: <54D17295.6090401@hitachi.com> Date: Wed, 04 Feb 2015 10:15:01 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Petr Mladek Cc: "David S. Miller" , Anil S Keshavamurthy , Ananth NMavinakayanahalli , Frederic Weisbecker , Steven Rostedt , Jiri Kosina , linux-kernel@vger.kernel.org, Ingo Molnar , Ingo Molnar Subject: Re: [PATCH] kprobes/x86: Check for invalid ftrace location in __recover_probed_insn() References: <1422980513-19327-1-git-send-email-pmladek@suse.cz> In-Reply-To: <1422980513-19327-1-git-send-email-pmladek@suse.cz> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2032 Lines: 59 (2015/02/04 1:21), 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. Looks good to me :) Acked-by: Masami Hiramatsu Thank you, > > Suggested-by: Masami Hiramatsu > Signed-off-by: Petr Mladek > --- > arch/x86/kernel/kprobes/core.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > > This is follow up for the patch ("[PATCH v2] kprobes/x86: Use 5-byte NOP > when the code might be modified by ftrace") based on the Masami's > suggestion, see https://lkml.org/lkml/2015/2/3/207 > > Let me know if I should merge this with the first patch and send v3. > > > 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); > + /* > * Use the current code if it is not modified by Kprobe > * and it cannot be modified by ftrace. > */ > -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com -- 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/