Re: [PATCH 2/3 v4] livepatch: add old_sympos as disambiguator field to klp_reloc
From: Petr Mladek
Date: Thu Nov 12 2015 - 09:32:06 EST
On Wed 2015-11-11 11:57:31, Josh Poimboeuf wrote:
> On Wed, Nov 11, 2015 at 10:29:00AM -0600, Chris J Arges wrote:
> > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> > index 26f9778..4eb8691 100644
> > --- a/kernel/livepatch/core.c
> > +++ b/kernel/livepatch/core.c
> > @@ -261,7 +222,7 @@ static int klp_find_verify_func_addr(struct klp_object *obj,
> > * object is either vmlinux or the kmod being patched).
> > */
> > static int klp_find_external_symbol(struct module *pmod, const char *name,
> > - unsigned long *addr)
> > + unsigned long *addr, unsigned long sympos)
> > {
> > const struct kernel_symbol *sym;
> >
>
> For "external" symbols, the object isn't specified by the user, and
> since sympos is per-object, the value of sympos is undefined. Instead
> I think it should always pass 0 to klp_find_object_symbol() below.
Heh, I always had troubles to understand the meaning of
this external stuff.
> In line with that, since reloc->external and reloc->sympos don't mix,
> maybe klp_write_object_relocations() should return -EINVAL if external
> is set and sympos is non-zero.
>
> > @@ -276,7 +237,7 @@ static int klp_find_external_symbol(struct module *pmod, const char *name,
> > preempt_enable();
> >
> > /* otherwise check if it's in another .o within the patch module */
> > - return klp_find_object_symbol(pmod->name, name, addr, 0);
> > + return klp_find_object_symbol(pmod->name, name, addr, sympos);
> > }
Please, do you have an example when this code will be used?
Do we really need to relocate symbols within the patch module this
way?
My understanding is that it would be used to relocate symbols
between various .o files that are used to produce the patch module.
IMHO, the only situation is that you want to access a static
symbol from another .o file. But this is not used in normal modules.
It does not look like a real life scenario.
It is indepednt on this patch set but it might make it easier.
What about doing this cleaup, first?