Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754021AbbGPHPQ (ORCPT ); Thu, 16 Jul 2015 03:15:16 -0400 Received: from mail9.hitachi.co.jp ([133.145.228.44]:51679 "EHLO mail9.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbbGPHPO (ORCPT ); Thu, 16 Jul 2015 03:15:14 -0400 X-AuditID: 85900ec0-9d7c9b9000001a57-a2-55a759e5eab9 Subject: [PATCH tip/master 2/3] kprobes: Use NOKPROBE_SYMBOL() in sample modules From: Masami Hiramatsu To: Ingo Molnar Cc: Pratyush Anand , Thomas Gleixner , Ingo Molnar , Linux Kernel Mailing List , "H. Peter Anvin" Date: Thu, 16 Jul 2015 16:10:57 +0900 Message-ID: <20150716071057.14218.66097.stgit@localhost.localdomain> In-Reply-To: <20150716071053.14218.82072.stgit@localhost.localdomain> References: <20150716071053.14218.82072.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2717 Lines: 77 Use NOKPROBE_SYMBOL() to protect handlers from kprobes in sample modules. Signed-off-by: Masami Hiramatsu Ananth N Mavinakayanahalli --- samples/kprobes/jprobe_example.c | 1 + samples/kprobes/kprobe_example.c | 3 +++ samples/kprobes/kretprobe_example.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/samples/kprobes/jprobe_example.c b/samples/kprobes/jprobe_example.c index 9119ac6..158d82c 100644 --- a/samples/kprobes/jprobe_example.c +++ b/samples/kprobes/jprobe_example.c @@ -34,6 +34,7 @@ static long jdo_fork(unsigned long clone_flags, unsigned long stack_start, jprobe_return(); return 0; } +NOKPROBE_SYMBOL(jdo_fork); static struct jprobe my_jprobe = { .entry = jdo_fork, diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index 366db1a..462d90f 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -46,6 +46,7 @@ static int handler_pre(struct kprobe *p, struct pt_regs *regs) /* A dump_stack() here will give a stack backtrace */ return 0; } +NOKPROBE_SYMBOL(handler_pre); /* kprobe post_handler: called after the probed instruction is executed */ static void handler_post(struct kprobe *p, struct pt_regs *regs, @@ -68,6 +69,7 @@ static void handler_post(struct kprobe *p, struct pt_regs *regs, p->addr, regs->ex1); #endif } +NOKPROBE_SYMBOL(handler_post); /* * fault_handler: this is called if an exception is generated for any @@ -81,6 +83,7 @@ static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr) /* Return 0 because we don't handle the fault. */ return 0; } +NOKPROBE_SYMBOL(handler_fault); static int __init kprobe_init(void) { diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c index 1041b67..d932c52 100644 --- a/samples/kprobes/kretprobe_example.c +++ b/samples/kprobes/kretprobe_example.c @@ -47,6 +47,7 @@ static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs) data->entry_stamp = ktime_get(); return 0; } +NOKPROBE_SYMBOL(entry_handler); /* * Return-probe handler: Log the return value and duration. Duration may turn @@ -66,6 +67,7 @@ static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs) func_name, retval, (long long)delta); return 0; } +NOKPROBE_SYMBOL(ret_handler); static struct kretprobe my_kretprobe = { .handler = ret_handler, -- 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/