Skip to content

Commit f5e547f

Browse files
jpoimboeJiri Kosina
authored andcommitted
livepatch: store function sizes
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> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 68ae4b2 commit f5e547f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎include/linux/livepatch.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
* @old_addr: the address of the function being patched
3838
* @kobj: kobject for sysfs resources
3939
* @stack_node: list node for klp_ops func_stack list
40+
* @old_size: size of the old function
41+
* @new_size: size of the new function
4042
* @patched: the func has been added to the klp_ops list
4143
*/
4244
struct klp_func {
@@ -56,6 +58,7 @@ struct klp_func {
5658
unsigned long old_addr;
5759
struct kobject kobj;
5860
struct list_head stack_node;
61+
unsigned long old_size, new_size;
5962
bool patched;
6063
};
6164

‎kernel/livepatch/core.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,22 @@ static int klp_init_object_loaded(struct klp_patch *patch,
584584
&func->old_addr);
585585
if (ret)
586586
return ret;
587+
588+
ret = kallsyms_lookup_size_offset(func->old_addr,
589+
&func->old_size, NULL);
590+
if (!ret) {
591+
pr_err("kallsyms size lookup failed for '%s'\n",
592+
func->old_name);
593+
return -ENOENT;
594+
}
595+
596+
ret = kallsyms_lookup_size_offset((unsigned long)func->new_func,
597+
&func->new_size, NULL);
598+
if (!ret) {
599+
pr_err("kallsyms size lookup failed for '%s' replacement\n",
600+
func->old_name);
601+
return -ENOENT;
602+
}
587603
}
588604

589605
return 0;

0 commit comments

Comments
 (0)