| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | #include <linux/kernel.h>
|
| 6 | #include <linux/module.h>
|
| 7 | #include <linux/kprobes.h>
|
| 8 |
|
| 9 | static bool has_post_handler = true;
|
| 10 | module_param(has_post_handler, bool, 0444);
|
| 11 |
|
| 12 | static void __kprobes post_handler(struct kprobe *p, struct pt_regs *regs,
|
| 13 | unsigned long flags)
|
| 14 | {
|
| 15 | }
|
| 16 |
|
| 17 | static struct kprobe kp = {
|
| 18 | .symbol_name = "cmdline_proc_show",
|
| 19 | };
|
| 20 |
|
| 21 | static int __init kprobe_init(void)
|
| 22 | {
|
| 23 | if (has_post_handler)
|
| 24 | kp.post_handler = post_handler;
|
| 25 |
|
| 26 | return register_kprobe(&kp);
|
| 27 | }
|
| 28 |
|
| 29 | static void __exit kprobe_exit(void)
|
| 30 | {
|
| 31 | unregister_kprobe(&kp);
|
| 32 | }
|
| 33 |
|
| 34 | module_init(kprobe_init)
|
| 35 | module_exit(kprobe_exit)
|
| 36 | MODULE_LICENSE("GPL");
|
| 37 | MODULE_AUTHOR("Michael Vetter <[email protected]>");
|
| 38 | MODULE_DESCRIPTION("Livepatch test: kprobe function");
|