Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1562854

[PATCH v4 12/15] livepatch: store function sizes

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v4 12/15] livepatch: store function sizes
Date 2017-01-19 17:00 +0100
Message-ID <t1ni2-3q2-21@gated-at.bofh.it> (permalink)
References <t1n8l-3mv-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


For the consistency model we'll need to know the sizes of the old and
new functions to determine if they're on the stacks of any tasks.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
---
 include/linux/livepatch.h |  3 +++
 kernel/livepatch/core.c   | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index 9787a63..6602b34 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -37,6 +37,8 @@
  * @old_addr:	the address of the function being patched
  * @kobj:	kobject for sysfs resources
  * @stack_node:	list node for klp_ops func_stack list
+ * @old_size:	size of the old function
+ * @new_size:	size of the new function
  * @patched:	the func has been added to the klp_ops list
  */
 struct klp_func {
@@ -56,6 +58,7 @@ struct klp_func {
 	unsigned long old_addr;
 	struct kobject kobj;
 	struct list_head stack_node;
+	unsigned long old_size, new_size;
 	bool patched;
 };
 
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 83c4949..10ba3a1 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -584,6 +584,22 @@ static int klp_init_object_loaded(struct klp_patch *patch,
 					     &func->old_addr);
 		if (ret)
 			return ret;
+
+		ret = kallsyms_lookup_size_offset(func->old_addr,
+						  &func->old_size, NULL);
+		if (!ret) {
+			pr_err("kallsyms size lookup failed for '%s'\n",
+			       func->old_name);
+			return -ENOENT;
+		}
+
+		ret = kallsyms_lookup_size_offset((unsigned long)func->new_func,
+						  &func->new_size, NULL);
+		if (!ret) {
+			pr_err("kallsyms size lookup failed for '%s' replacement\n",
+			       func->old_name);
+			return -ENOENT;
+		}
 	}
 
 	return 0;
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 00/15] livepatch: hybrid consistency model Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 16:50 +0100
  [PATCH v4 02/15] x86/entry: define _TIF_ALLWORK_MASK flags explicitly Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 16:50 +0100
  [PATCH v4 15/15] livepatch: allow removal of a disabled patch Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 16:50 +0100
  [PATCH v4 04/15] livepatch/x86: add TIF_PATCH_PENDING thread flag Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 17:00 +0100
  [PATCH v4 12/15] livepatch: store function sizes Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 17:00 +0100
  [PATCH v4 06/15] livepatch/s390: reorganize TIF thread flag bits Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 17:00 +0100
  [PATCH v4 11/15] livepatch: use kstrtobool() in enabled_store() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 17:00 +0100
  [PATCH v4 03/15] livepatch: create temporary klp_update_patch_state() stub Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 17:00 +0100
    Re: [PATCH v4 03/15] livepatch: create temporary klp_update_patch_state()  stub Miroslav Benes <mbenes@suse.cz> - 2017-01-27 10:00 +0100
  [PATCH v4 10/15] livepatch: move patching functions into patch.c Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-19 17:00 +0100

csiph-web