From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754323AbbK3UqR (ORCPT ); Mon, 30 Nov 2015 15:46:17 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52848 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbbK3UqP (ORCPT ); Mon, 30 Nov 2015 15:46:15 -0500 Date: Mon, 30 Nov 2015 14:46:18 -0600 From: Chris J Arges To: Miroslav Benes Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, jeyu@redhat.com, Seth Jennings , Vojtech Pavlik Subject: Re: [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to klp_reloc Message-ID: <20151130204617.GB7648@canonical.com> References: <1447693391-10065-1-git-send-email-chris.j.arges@canonical.com> <1448040325-32498-1-git-send-email-chris.j.arges@canonical.com> <1448040325-32498-3-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: 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 On Mon, Nov 23, 2015 at 10:52:23AM +0100, Miroslav Benes wrote: > On Fri, 20 Nov 2015, Chris J Arges wrote: > > [...] > > > @@ -272,6 +233,7 @@ static int klp_write_object_relocations(struct module *pmod, > > struct klp_object *obj) > > { > > int ret; > > + unsigned long val; > > struct klp_reloc *reloc; > > > > if (WARN_ON(!klp_is_object_loaded(obj))) > > @@ -281,29 +243,26 @@ 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, > > - 0, &reloc->val); > > - if (ret) > > - return ret; > > - } > > + /* discover the address of the referenced symbol */ > > + if (reloc->external) { > > + if (reloc->sympos > 0) { > > + pr_err("non-zero sympos for external reloc symbol '%s' is not supported\n", > > + reloc->name); > > + return -EINVAL; > > + } > > + ret = klp_find_external_symbol(pmod, reloc->name, &val); > > + } else > > + ret = klp_find_object_symbol(obj->mod->name, > > + reloc->name, > > + reloc->sympos, > > + &val); > > I think this will cause an unwanted effect if a relocation is for vmlinux > symbol. obj->mod is NULL in that case. So obj->name should be there. Can > you test it with kpatch, Chris, please? If that is possible. > > Thanks, > Miroslav > Yes I need to fix this, an option would be to use: ret = klp_find_object_symbol(obj->name ? obj->name : obj->mod->name, reloc->name, 0, &reloc->val); Testing with kpatch will require some modifications as the structures are different. --chris