| 1 | |
| 2 | |
| 3 |
|
| 4 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
| 5 |
|
| 6 | #include <linux/module.h>
|
| 7 | #include <linux/kernel.h>
|
| 8 | #include <linux/livepatch.h>
|
| 9 | #include <linux/seq_file.h>
|
| 10 |
|
| 11 | static int livepatch_mod_target_show(struct seq_file *m, void *v)
|
| 12 | {
|
| 13 | seq_printf(m, "%s: %s\n", THIS_MODULE->name,
|
| 14 | "this has been live patched");
|
| 15 | return 0;
|
| 16 | }
|
| 17 |
|
| 18 | static struct klp_func funcs[] = {
|
| 19 | {
|
| 20 | .old_name = "test_klp_mod_target_show",
|
| 21 | .new_func = livepatch_mod_target_show,
|
| 22 | },
|
| 23 | {},
|
| 24 | };
|
| 25 |
|
| 26 | static struct klp_object objs[] = {
|
| 27 | {
|
| 28 | .name = "test_klp_mod_target",
|
| 29 | .funcs = funcs,
|
| 30 | },
|
| 31 | {},
|
| 32 | };
|
| 33 |
|
| 34 | static struct klp_patch patch = {
|
| 35 | .mod = THIS_MODULE,
|
| 36 | .objs = objs,
|
| 37 | };
|
| 38 |
|
| 39 | static int test_klp_mod_patch_init(void)
|
| 40 | {
|
| 41 | return klp_enable_patch(&patch);
|
| 42 | }
|
| 43 |
|
| 44 | static void test_klp_mod_patch_exit(void)
|
| 45 | {
|
| 46 | }
|
| 47 |
|
| 48 | module_init(test_klp_mod_patch_init);
|
| 49 | module_exit(test_klp_mod_patch_exit);
|
| 50 | MODULE_LICENSE("GPL");
|
| 51 | MODULE_INFO(livepatch, "Y");
|
| 52 | MODULE_AUTHOR("Pablo Hugen <[email protected]>");
|
| 53 | MODULE_DESCRIPTION("Livepatch test: patch for module-provided function");
|