lkml.org 
[lkml]   [2015]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] livepatch: x86: make kASLR logic more accurate
On Sat, 25 Apr 2015, Minfei Huang wrote:

> > diff --git a/arch/x86/include/asm/livepatch.h b/arch/x86/include/asm/livepatch.h
> > index 2d29197..84a3247 100644
> > --- a/arch/x86/include/asm/livepatch.h
> > +++ b/arch/x86/include/asm/livepatch.h
> > @@ -23,8 +23,12 @@
> >
> > #include <linux/module.h>
> > #include <linux/ftrace.h>
> > +#include <asm/setup.h>
> >
> > #ifdef CONFIG_LIVEPATCH
> > +
> > +extern unsigned long klp_vmlinux_relocation_offset(void);
> > +
> > static inline int klp_check_compiler_support(void)
> > {
> > #ifndef CC_USING_FENTRY
> > diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c
> > index ff3c3101d..6df7902 100644
> > --- a/arch/x86/kernel/livepatch.c
> > +++ b/arch/x86/kernel/livepatch.c
> > @@ -88,3 +88,8 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
> >
> > return ret;
> > }
> > +
> > +unsigned long klp_vmlinux_relocation_offset(void)
> > +{
> > + return (unsigned long)&_text - __START_KERNEL;
> > +}
>
> Is it possible to put above function into arch/x86/include/asm/setup.h?
> It is more elegant, so that the function is re-used by other module.

Yup, makes sense. I will take that into account in v3. At least x86 module
loader can already immediately make use of that.

> > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> > index 284e269..ff4c35c 100644
> > --- a/kernel/livepatch/core.c
> > +++ b/kernel/livepatch/core.c
> > @@ -234,8 +234,9 @@ static int klp_find_verify_func_addr(struct klp_object *obj,
> > int ret;
> >
> > #if defined(CONFIG_RANDOMIZE_BASE)
> > - /* KASLR is enabled, disregard old_addr from user */
> > - func->old_addr = 0;
> > + /* If KASLR has been enabled, adjust old_addr accordingly */
> > + if (kaslr_enabled())
> > + func->old_addr += klp_vmlinux_relocation_offset();
>
> Since KASLR only works for x86 arch now, it is better to put it into the
> specfied arch (x86 now), or implement a weak function to let be overwritten
> by specified arch.

I responded to Josh on this matter already.

Thanks,

--
Jiri Kosina
SUSE Labs


\
 
 \ /
  Last update: 2015-04-25 23:21    [W:0.051 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site