lkml.org 
[lkml]   [2016]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 4/6] livepatch: reuse module loader code to write relocations
On Mon, Mar 21, 2016 at 05:31:57PM +0100, Petr Mladek wrote:
> > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> > index 780f00c..2aa20fa 100644
> > --- a/kernel/livepatch/core.c
> > +++ b/kernel/livepatch/core.c
> > +static int klp_resolve_symbols(Elf_Shdr *relasec, struct module *pmod)
> > +{
> > + int i, cnt, vmlinux, ret;
> > + struct klp_buf bufs = {0};
> > + Elf_Rela *relas;
> > + Elf_Sym *sym;
> > + char *symname;
> > + unsigned long sympos;
> > +
> > + relas = (Elf_Rela *) relasec->sh_addr;
> > + /* For each rela in this klp relocation section */
> > + for (i = 0; i < relasec->sh_size / sizeof(Elf_Rela); i++) {
> > + sym = pmod->core_kallsyms.symtab + ELF_R_SYM(relas[i].r_info);
> > + if (sym->st_shndx != SHN_LIVEPATCH)
> > + return -EINVAL;
> > +
> > + klp_clear_buf(&bufs);
> > +
> > + /* Format: .klp.sym.objname.symbol_name,sympos */
> > + symname = pmod->core_kallsyms.strtab + sym->st_name;
> > + cnt = sscanf(symname, ".klp.sym.%64[^.].%128[^,],%lu",
> > + bufs.objname, bufs.symname, &sympos);
>
> Note that MODULE_NAME_LEN even is not 64. It is defined by:
>
> #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
>
> I strongly suggest to use the proposal from Josh.

Hm, looks like my suggestion to use __stringify(MODULE_NAME_LEN) doesn't
work. It results in the string "MODULE_NAME_LEN". Which surprises me:
isn't is supposed to resolve the macro before applying the '#' operation
to it?

I was going to suggest another idea: hard-code it at 63 and then do
something like

BUILD_BUG_ON(MODULE_NAME_LEN != 64)

But you're right... it's not even 64!

Need to think on this some more...

--
Josh

\
 
 \ /
  Last update: 2016-03-21 18:21    [W:0.160 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site