Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751472AbbDYUo6 (ORCPT ); Sat, 25 Apr 2015 16:44:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36380 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750870AbbDYUo4 (ORCPT ); Sat, 25 Apr 2015 16:44:56 -0400 Date: Sat, 25 Apr 2015 22:44:55 +0200 (CEST) From: Jiri Kosina To: Minfei Huang cc: Josh Poimboeuf , Seth Jennings , Vojtech Pavlik , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] livepatch: x86: make kASLR logic more accurate In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2333 Lines: 69 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 > > #include > > +#include > > > > #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 -- 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/