GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing codebrowser.dev — livepatch-sample.c source code [linux/samples/livepatch/livepatch-sample.c] - Codebrowser

Codebrowser logo
About
Contact
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * livepatch-sample.c - Kernel Live Patching Sample Module
4 *
5 * Copyright (C) 2014 Seth Jennings <[email protected]>
6 */
7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/livepatch.h>
13
14/*
15 * This (dumb) live patch overrides the function that prints the
16 * kernel boot cmdline when /proc/cmdline is read.
17 *
18 * Example:
19 *
20 * $ cat /proc/cmdline
21 * <your cmdline>
22 *
23 * $ insmod livepatch-sample.ko
24 * $ cat /proc/cmdline
25 * this has been live patched
26 *
27 * $ echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled
28 * $ cat /proc/cmdline
29 * <your cmdline>
30 */
31
32#include <linux/seq_file.h>
33static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
34{
35 seq_printf(m, fmt: "%s\n", "this has been live patched");
36 return 0;
37}
38
39static struct klp_func funcs[] = {
40 {
41 .old_name = "cmdline_proc_show",
42 .new_func = livepatch_cmdline_proc_show,
43 }, { }
44};
45
46static struct klp_object objs[] = {
47 {
48 /* name being NULL means vmlinux */
49 .funcs = funcs,
50 }, { }
51};
52
53static struct klp_patch patch = {
54 .mod = THIS_MODULE,
55 .objs = objs,
56};
57
58static int livepatch_init(void)
59{
60 return klp_enable_patch(&patch);
61}
62
63static void livepatch_exit(void)
64{
65}
66
67module_init(livepatch_init);
68module_exit(livepatch_exit);
69MODULE_DESCRIPTION("Kernel Live Patching Sample Module");
70MODULE_LICENSE("GPL");
71MODULE_INFO(livepatch, "Y");
72

source code of linux/samples/livepatch/livepatch-sample.c

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.