Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1692060
| From | Jason Baron <jbaron@akamai.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/3] livepatch: Add a sysctl livepatch_mode for atomic replace |
| Date | 2017-07-19 19:40 +0200 |
| Message-ID | <u5177-3pP-39@gated-at.bofh.it> (permalink) |
| References | <u50Xo-3mb-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Introduce a sysctl knob such that by default livepatch is not in
'atomic replace' mode. A '0' in /proc/sys/kernel/livepatch_mode means the
current default mode, while a '1' means do atomic replace.
Signed-off-by: Jason Baron <jbaron@akamai.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Miroslav Benes <mbenes@suse.cz>
Cc: Petr Mladek <pmladek@suse.com>
---
include/linux/livepatch.h | 8 ++++++++
kernel/livepatch/core.c | 5 +++++
kernel/sysctl.c | 12 ++++++++++++
3 files changed, 25 insertions(+)
diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index 6fd7222..08e760a 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -35,6 +35,14 @@
#define KLP_UNPATCHED 0
#define KLP_PATCHED 1
+/* livepatch mode */
+
+extern int sysctl_livepatch_mode;
+enum {
+ LIVEPATCH_MODE_DEFAULT,
+ LIVEPATCH_MODE_REPLACE,
+};
+
/**
* struct klp_func - function structure for live patching
* @old_name: name of the function to be patched
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index bf353da..b1df5c4 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -49,6 +49,8 @@ static LIST_HEAD(klp_patches);
static struct kobject *klp_root_kobj;
+int sysctl_livepatch_mode;
+
static bool klp_is_module(struct klp_object *obj)
{
return obj->name;
@@ -643,6 +645,9 @@ static int klp_init_patch_no_ops(struct klp_patch *patch)
if (patch->list.prev == &klp_patches)
return 0;
+ if (sysctl_livepatch_mode != LIVEPATCH_MODE_REPLACE)
+ return 0;
+
prev_patch = list_prev_entry(patch, list);
klp_for_each_object(prev_patch, prev_obj, &prev_o_iter) {
if (!klp_is_object_loaded(prev_obj))
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 4dfba1a..3a0a1f6 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -67,6 +67,7 @@
#include <linux/kexec.h>
#include <linux/bpf.h>
#include <linux/mount.h>
+#include <linux/livepatch.h>
#include <linux/uaccess.h>
#include <asm/processor.h>
@@ -1203,6 +1204,17 @@ static struct ctl_table kern_table[] = {
.extra2 = &one,
},
#endif
+#ifdef CONFIG_LIVEPATCH
+ {
+ .procname = "livepatch_mode",
+ .data = &sysctl_livepatch_mode,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = &zero,
+ .extra2 = &one,
+ },
+#endif
{ }
};
--
2.6.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] livepatch: introduce atomic replace Jason Baron <jbaron@akamai.com> - 2017-07-19 19:40 +0200
[PATCH 3/3] livepatch: Add a sysctl livepatch_mode for atomic replace Jason Baron <jbaron@akamai.com> - 2017-07-19 19:40 +0200
[PATCH 2/3] livepatch: add atomic replace Jason Baron <jbaron@akamai.com> - 2017-07-19 19:50 +0200
Re: [PATCH 0/3] livepatch: introduce atomic replace Miroslav Benes <mbenes@suse.cz> - 2017-07-21 15:10 +0200
Re: [PATCH 0/3] livepatch: introduce atomic replace Jason Baron <jbaron@akamai.com> - 2017-07-21 20:00 +0200
csiph-web