1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/livepatch.h>
- #include <linux/seq_file.h>
- static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
- {
- seq_printf(m, "%s\n", "this has been live patched");
- return 0;
- }
- static struct klp_func funcs[] = {
- {
- .old_name = "cmdline_proc_show",
- .new_func = livepatch_cmdline_proc_show,
- }, { }
- };
- static struct klp_object objs[] = {
- {
-
- .funcs = funcs,
- }, { }
- };
- static struct klp_patch patch = {
- .mod = THIS_MODULE,
- .objs = objs,
- };
- static int livepatch_init(void)
- {
- int ret;
- ret = klp_register_patch(&patch);
- if (ret)
- return ret;
- ret = klp_enable_patch(&patch);
- if (ret) {
- WARN_ON(klp_unregister_patch(&patch));
- return ret;
- }
- return 0;
- }
- static void livepatch_exit(void)
- {
- WARN_ON(klp_disable_patch(&patch));
- WARN_ON(klp_unregister_patch(&patch));
- }
- module_init(livepatch_init);
- module_exit(livepatch_exit);
- MODULE_LICENSE("GPL");
- MODULE_INFO(livepatch, "Y");
|