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


Groups > linux.kernel > #1280457

Re: [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to klp_reloc

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to klp_reloc
Date 2015-12-01 02:20 +0100
Message-ID <qAHLQ-2RM-5@gated-at.bofh.it> (permalink)
References <qvvrX-1EC-5@gated-at.bofh.it> <qwXFw-1Np-17@gated-at.bofh.it> <qwXFw-1Np-23@gated-at.bofh.it> <qxW4H-8tT-17@gated-at.bofh.it> <qADyy-8ry-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Nov 30, 2015 at 02:46:18PM -0600, Chris J Arges wrote:
> 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);

Instead of

  'obj->name ? obj->name : obj->mod->name'
  
I think it can just be 'obj->name'.

If it's patching a module, obj->name will be the module name, otherwise
it will be NULL (for patching vmlinux).  klp_find_object_symbol() is
equipped to handle it either way.

-- 
Josh
--
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/

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


Thread

[PATCH 0/3 v8] livepatch: disambiguate symbols with the same name Chris J Arges <chris.j.arges@canonical.com> - 2015-11-20 18:30 +0100
  [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges <chris.j.arges@canonical.com> - 2015-11-20 18:30 +0100
    Re: [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to  klp_reloc Miroslav Benes <mbenes@suse.cz> - 2015-11-23 11:00 +0100
      Re: [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to  klp_reloc Chris J Arges <chris.j.arges@canonical.com> - 2015-11-30 21:50 +0100
        Re: [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to  klp_reloc Josh Poimboeuf <jpoimboe@redhat.com> - 2015-12-01 02:20 +0100
  [PATCH 3/3 v8] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges <chris.j.arges@canonical.com> - 2015-11-20 18:30 +0100
    Re: [PATCH 3/3 v8] livepatch: function,sympos scheme in livepatch  sysfs directory Miroslav Benes <mbenes@suse.cz> - 2015-11-23 10:50 +0100
  [PATCH 1/3 v8] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges <chris.j.arges@canonical.com> - 2015-11-20 18:30 +0100
    Re: [PATCH 1/3 v8] livepatch: add old_sympos as disambiguator field  to klp_func Miroslav Benes <mbenes@suse.cz> - 2015-11-23 10:50 +0100
  [PATCH 2/3 v9] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges <chris.j.arges@canonical.com> - 2015-12-02 03:50 +0100
  [PATCH 0/3 v9] livepatch: disambiguate symbols with the same name Chris J Arges <chris.j.arges@canonical.com> - 2015-12-02 03:50 +0100
    [PATCH 3/3 v9] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges <chris.j.arges@canonical.com> - 2015-12-02 03:50 +0100
    [PATCH 1/3 v9] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges <chris.j.arges@canonical.com> - 2015-12-02 03:50 +0100
    Re: [PATCH 0/3 v9] livepatch: disambiguate symbols with the same name Petr Mladek <pmladek@suse.com> - 2015-12-02 16:30 +0100
    Re: [PATCH 0/3 v9] livepatch: disambiguate symbols with the same name Josh Poimboeuf <jpoimboe@redhat.com> - 2015-12-03 19:10 +0100
    Re: [PATCH 0/3 v9] livepatch: disambiguate symbols with the same  name Jiri Kosina <jikos@kernel.org> - 2015-12-03 23:10 +0100

csiph-web