Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964890AbbBIRbh (ORCPT ); Mon, 9 Feb 2015 12:31:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55459 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964825AbbBIRbc (ORCPT ); Mon, 9 Feb 2015 12:31:32 -0500 From: Josh Poimboeuf To: Seth Jennings , Jiri Kosina , Vojtech Pavlik Cc: Masami Hiramatsu , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/9] livepatch: get function sizes Date: Mon, 9 Feb 2015 11:31:16 -0600 Message-Id: <8dd54217503f9050fbd555631a9f7affdfb29212.1423499826.git.jpoimboe@redhat.com> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2028 Lines: 69 For the consistency model we'll need to know the sizes of the old and new functions to determine if they're on any task stacks. Signed-off-by: Josh Poimboeuf --- include/linux/livepatch.h | 3 +++ kernel/livepatch/core.c | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h index 22a67d1..0e65b4d 100644 --- a/include/linux/livepatch.h +++ b/include/linux/livepatch.h @@ -37,6 +37,8 @@ * @kobj: kobject for sysfs resources * @state: tracks function-level patch application state * @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 { /* internal */ struct kobject kobj; struct list_head stack_node; + unsigned long old_size, new_size; int patched; }; diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 0c09eba..85d4ef7 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -197,8 +197,25 @@ static int klp_find_verify_func_addr(struct klp_object *obj, else ret = klp_verify_vmlinux_symbol(func->old_name, func->old_addr); + if (ret) + return ret; - return ret; + ret = kallsyms_lookup_size_offset(func->old_addr, &func->old_size, + NULL); + if (!ret) { + pr_err("kallsyms lookup failed for '%s'\n", func->old_name); + return -EINVAL; + } + + ret = kallsyms_lookup_size_offset((unsigned long)func->new_func, + &func->new_size, NULL); + if (!ret) { + pr_err("kallsyms lookup failed for '%s' replacement\n", + func->old_name); + return -EINVAL; + } + + return 0; } /* -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/