Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933401AbbKMQnD (ORCPT ); Fri, 13 Nov 2015 11:43:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:48236 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932858AbbKMQm6 (ORCPT ); Fri, 13 Nov 2015 11:42:58 -0500 Date: Fri, 13 Nov 2015 17:42:57 +0100 From: Petr Mladek To: Chris J Arges Cc: live-patching@vger.kernel.org, jeyu@redhat.com, Josh Poimboeuf , Seth Jennings , Jiri Kosina , Vojtech Pavlik , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/4 v5] livepatch: add sympos as disambiguator field to klp_reloc Message-ID: <20151113164256.GX2599@pathway.suse.cz> References: <1447259366-7055-1-git-send-email-chris.j.arges@canonical.com> <1447347595-30728-1-git-send-email-chris.j.arges@canonical.com> <1447347595-30728-4-git-send-email-chris.j.arges@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447347595-30728-4-git-send-email-chris.j.arges@canonical.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2577 Lines: 72 On Thu 2015-11-12 10:59:52, Chris J Arges wrote: > In cases of duplicate symbols, sympos will be used to disambiguate instead > of val. By default sympos will be 0, and patching will only succeed if > the symbol is unique. Specifying a positive value will ensure that > occurrence of the symbol in kallsyms for the patched object will be used > for patching if it is valid. > > Remove klp_verify_callback, klp_verify_args and klp_verify_vmlinux_symbol > as they are no longer used. > > >From the klp_reloc structure remove val, as it can be refactored as a > local variable in klp_write_object_relocations. > > Signed-off-by: Chris J Arges > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > index 4cd079c..071895f 100644 > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -275,29 +237,30 @@ static int klp_write_object_relocations(struct module *pmod, > return -EINVAL; > > for (reloc = obj->relocs; reloc->name; reloc++) { > - if (!klp_is_module(obj)) { > - ret = klp_verify_vmlinux_symbol(reloc->name, > - reloc->val); > - if (ret) > - return ret; > - } else { > - /* module, reloc->val needs to be discovered */ > - if (reloc->external) > - ret = klp_find_external_symbol(pmod, > - reloc->name, > - &reloc->val); > - else > - ret = klp_find_object_symbol(obj->mod->name, > - reloc->name, > - &reloc->val, 0); > - if (ret) > - return ret; > - } > + /* discover the address of the referenced symbol */ > + if (reloc->external) { > + /* > + * external symbols aren't specified by the user > + * therefore sympos should not be used > + */ > + if (reloc->sympos) { > + pr_err("symbol '%s' is external and has sympos %lu\n", > + reloc->name, reloc->sympos); > + return -EINVAL; > + } To be precise, reloc->sympos == 1 is a valid value. Note that it will show "symbol,1" in sysfs. I suggest the following to keep it simple: if (reloc->sympos && (reloc->sympos != 1)) { pr_err("relocated external symbols must be unique but '%s' has sympos %lu\n", reloc->name, reloc->sympos); return -EINVAL; } Then we could even get rid of the comment. Huh, I am looking forward to get rid of the external symbols ;-) Thank you, Petr -- 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/