Skip to content

Commit

Permalink
samples/kprobes: add a new module parameter
Browse files Browse the repository at this point in the history
Add a new module parameter which can be used as the symbol name.

Without this patch, we can only test the "_do_fork" function with this
kernel module.  With this patch, the module becomes more flexible; we
can test any functions with this module with

	# insmod kprobe_example.ko symbol="xxx"

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Huang Shijie <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Steve Capper <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Huang Shijie authored and torvalds committed May 21, 2016
1 parent 603ac5d commit d04659a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion samples/kprobes/kprobe_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
#include <linux/module.h>
#include <linux/kprobes.h>

#define MAX_SYMBOL_LEN 64
static char symbol[MAX_SYMBOL_LEN] = "_do_fork";
module_param_string(symbol, symbol, sizeof(symbol), 0644);

/* For each probe you need to allocate a kprobe structure */
static struct kprobe kp = {
.symbol_name = "_do_fork",
.symbol_name = symbol,
};

/* kprobe pre_handler: called just before the probed instruction is executed */
Expand Down

0 comments on commit d04659a

Please sign in to comment.