summaryrefslogtreecommitdiffstats
path: root/samples/kprobes/kprobe_example.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2020-03-26 23:50:11 +0900
committerThomas Gleixner <tglx@linutronix.de>2020-05-12 17:15:33 +0200
commitd85eaa9411472a99de4b5732cb59c8bae629d5f1 (patch)
tree4d35f76035c78c48da9b96cd298d462643342fdc /samples/kprobes/kprobe_example.c
parent16db6264c93d2d7df9eb8be5d9eb717ab30105fe (diff)
downloadlinux-d85eaa9411472a99de4b5732cb59c8bae629d5f1.tar.bz2
samples/kprobes: Add __kprobes and NOKPROBE_SYMBOL() for handlers.
Add __kprobes and NOKPROBE_SYMBOL() for sample kprobe handlers. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200505134059.878578033@linutronix.de
Diffstat (limited to 'samples/kprobes/kprobe_example.c')
-rw-r--r--samples/kprobes/kprobe_example.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
index d693c23a85e8..501911d1b327 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -25,7 +25,7 @@ static struct kprobe kp = {
};
/* kprobe pre_handler: called just before the probed instruction is executed */
-static int handler_pre(struct kprobe *p, struct pt_regs *regs)
+static int __kprobes handler_pre(struct kprobe *p, struct pt_regs *regs)
{
#ifdef CONFIG_X86
pr_info("<%s> pre_handler: p->addr = 0x%p, ip = %lx, flags = 0x%lx\n",
@@ -54,7 +54,7 @@ static int handler_pre(struct kprobe *p, struct pt_regs *regs)
}
/* kprobe post_handler: called after the probed instruction is executed */
-static void handler_post(struct kprobe *p, struct pt_regs *regs,
+static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs,
unsigned long flags)
{
#ifdef CONFIG_X86
@@ -90,6 +90,8 @@ 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() is also available */
+NOKPROBE_SYMBOL(handler_fault);
static int __init kprobe_init(void)
{