Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170215135824.tflwuf3esu2npwwo@pd.tnic>
Date: Wed, 15 Feb 2017 14:58:24 +0100
From: Borislav Petkov <bp@...e.de>
To: Thomas Garnier <thgarnie@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
	"H . Peter Anvin" <hpa@...or.com>,
	Andrey Ryabinin <aryabinin@...tuozzo.com>,
	Alexander Potapenko <glider@...gle.com>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	Kees Cook <keescook@...omium.org>,
	Andy Lutomirski <luto@...nel.org>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Andy Lutomirski <luto@...capital.net>,
	"Rafael J . Wysocki" <rjw@...ysocki.net>,
	Len Brown <len.brown@...el.com>, Pavel Machek <pavel@....cz>,
	Jiri Kosina <jikos@...nel.org>,
	Matt Fleming <matt@...eblueprint.co.uk>,
	Ard Biesheuvel <ard.biesheuvel@...aro.org>,
	Boris Ostrovsky <boris.ostrovsky@...cle.com>,
	Juergen Gross <jgross@...e.com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Peter Zijlstra <peterz@...radead.org>,
	Christian Borntraeger <borntraeger@...ibm.com>,
	"Luis R . Rodriguez" <mcgrof@...nel.org>,
	He Chen <he.chen@...ux.intel.com>, Brian Gerst <brgerst@...il.com>,
	Stanislaw Gruszka <sgruszka@...hat.com>,
	Arnd Bergmann <arnd@...db.de>,
	Adam Buchbinder <adam.buchbinder@...il.com>,
	Dave Hansen <dave.hansen@...el.com>,
	Vitaly Kuznetsov <vkuznets@...hat.com>,
	Josh Poimboeuf <jpoimboe@...hat.com>,
	Tim Chen <tim.c.chen@...ux.intel.com>,
	Rik van Riel <riel@...hat.com>, Andi Kleen <ak@...ux.intel.com>,
	Jiri Olsa <jolsa@...hat.com>, Michael Ellerman <mpe@...erman.id.au>,
	Joerg Roedel <joro@...tes.org>, Paolo Bonzini <pbonzini@...hat.com>,
	Radim Krčmář <rkrcmar@...hat.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org, kasan-dev@...glegroups.com,
	linux-pm@...r.kernel.org, linux-efi@...r.kernel.org,
	xen-devel@...ts.xenproject.org, lguest@...ts.ozlabs.org,
	kvm@...r.kernel.org, kernel-hardening@...ts.openwall.com
Subject: Re: [PATCH v3 1/4] x86/mm: Adapt MODULES_END based on Fixmap section
 size

On Tue, Feb 14, 2017 at 11:42:56AM -0800, Thomas Garnier wrote:
> This patch aligns MODULES_END to the beginning of the Fixmap section.
> It optimizes the space available for both sections. The address is
> pre-computed based on the number of pages required by the Fixmap
> section.
> 
> It will allow GDT remapping in the Fixmap section. The current
> MODULES_END static address does not provide enough space for the kernel
> to support a large number of processors.
> 
> Signed-off-by: Thomas Garnier <thgarnie@...gle.com>
> ---
> Based on next-20170213
> ---
>  arch/x86/include/asm/fixmap.h           | 8 ++++++++
>  arch/x86/include/asm/pgtable_64_types.h | 3 ---
>  arch/x86/kernel/module.c                | 1 +
>  arch/x86/mm/dump_pagetables.c           | 1 +
>  arch/x86/mm/kasan_init_64.c             | 1 +
>  5 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
> index 8554f960e21b..20231189e0e3 100644
> --- a/arch/x86/include/asm/fixmap.h
> +++ b/arch/x86/include/asm/fixmap.h
> @@ -132,6 +132,14 @@ enum fixed_addresses {
>  
>  extern void reserve_top_address(unsigned long reserve);
>  
> +/* On 64-bit, the module sections ends with the start of the fixmap */
> +#ifdef CONFIG_X86_64
> +#define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
> +#define MODULES_END   __fix_to_virt(__end_of_fixed_addresses + 1)
> +#define MODULES_LEN   (MODULES_END - MODULES_VADDR)
> +#endif /* CONFIG_X86_64 */

JFYI: so there's another patchset which adds KERNEL_MAPPING_SIZE:

https://lkml.kernel.org/r/1486040077-3719-1-git-send-email-bhe@redhat.com

and makes it a 1G, i.e., the KASLR default. I guess the above will have
to be KERNEL_MAPPING_SIZE then.

And why are you moving those to fixmap.h? What's wrong with
including fixmap.h into pgtable_64_types.h so that you can get
__end_of_fixed_addresses?

FWIW, I didn't even have to add any includes with my .config, i.e., that builds:

---
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..eda7fa856fa9 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,7 @@ typedef struct { pteval_t pte; } pte_t;
 #endif /* CONFIG_RANDOMIZE_MEMORY */
 #define VMALLOC_END	(VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
 #define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
-#define MODULES_END      _AC(0xffffffffff000000, UL)
+#define MODULES_END   __fix_to_virt(__end_of_fixed_addresses + 1)
 #define MODULES_LEN   (MODULES_END - MODULES_VADDR)
 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
---

but I wouldn't be surprised if some strange configuration would need it.

>  #define FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
>  #define FIXADDR_START		(FIXADDR_TOP - FIXADDR_SIZE)
>  
> diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
> index 3a264200c62f..de8bace10200 100644
> --- a/arch/x86/include/asm/pgtable_64_types.h
> +++ b/arch/x86/include/asm/pgtable_64_types.h
> @@ -66,9 +66,6 @@ typedef struct { pteval_t pte; } pte_t;
>  #define VMEMMAP_START	__VMEMMAP_BASE
>  #endif /* CONFIG_RANDOMIZE_MEMORY */
>  #define VMALLOC_END	(VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
> -#define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
> -#define MODULES_END      _AC(0xffffffffff000000, UL)

How much of an ABI breakage would that be? See
Documentation/x86/x86_64/mm.txt.

With my .config MODULES_END becomes 0xffffffffff1fe000 and it'll remain
dynamic depending on .config. No idea how much in userspace relies on
MODULES_END being static 0xffffffffff000000...

Hmm.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.