[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200423011003.GA20432@redhat.com>
Date: Wed, 22 Apr 2020 21:10:03 -0400
From: Joe Lawrence <joe.lawrence@...hat.com>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
Jessica Yu <jeyu@...nel.org>
Subject: Re: [PATCH v2 2/9] livepatch: Apply vmlinux-specific KLP relocations
early
On Mon, Apr 20, 2020 at 02:11:17PM -0500, Josh Poimboeuf wrote:
> On Mon, Apr 20, 2020 at 03:01:41PM -0400, Joe Lawrence wrote:
> > > > ... apply_relocations() is also iterating over the section headers (the
> > > > diff context doesn't show it here, but i is an incrementing index over
> > > > sechdrs[]).
> > > >
> > > > So if there is more than one KLP relocation section, we'll process them
> > > > multiple times. At least the x86 relocation code will detect this and
> > > > fail the module load with an invalid relocation (existing value not
> > > > zero).
> > >
> > > Ah, yes, good catch!
> > >
> >
> > The same test case passed with a small modification to push the foreach
> > KLP section part to a kernel/livepatch/core.c local function and
> > exposing the klp_resolve_symbols() + apply_relocate_add() for a given
> > section to kernel/module.c. Something like following...
>
> I came up with something very similar, though I named them
> klp_apply_object_relocs() and klp_apply_section_relocs() and changed the
> argument order a bit (module first). Since it sounds like you have a
> test, could you try this one?
>
> diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
> index 533359e48c39..fb1a3de39726 100644
> --- a/include/linux/livepatch.h
> +++ b/include/linux/livepatch.h
>
> [ ... snip ... ]
>
> @@ -245,10 +245,10 @@ static inline void klp_update_patch_state(struct task_struct *task) {}
> static inline void klp_copy_process(struct task_struct *child) {}
>
> static inline
> -int klp_write_relocations(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
> - const char *shstrtab, const char *strtab,
> - unsigned int symindex, struct module *pmod,
> - const char *objname)
> +int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
> + const char *shstrtab, const char *strtab,
> + unsigned int symindex, unsigned int secindex,
> + const char *objname);
^^
Whoops, stray semicolon in !CONFIG_LIVEPATCH case. I found it by
botching my cross-compiling .config, but the build-bot might find it
when you push your branch.
> {
> return 0;
> }
-- Joe
Powered by blists - more mailing lists