Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <68119f42-cb1b-fd3e-3820-7cf235e607e5@nextfour.com>
Date: Tue, 9 Aug 2016 08:16:46 +0300
From: Mika Penttilä <mika.penttila@...tfour.com>
To: Thomas Garnier <thgarnie@...gle.com>, Thomas Gleixner
	<tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, "H . Peter Anvin"
	<hpa@...or.com>, Borislav Petkov <bp@...e.de>, Joerg Roedel
	<jroedel@...e.de>, Dave Young <dyoung@...hat.com>, "Rafael J . Wysocki"
	<rafael.j.wysocki@...el.com>, Lv Zheng <lv.zheng@...el.com>, Baoquan He
	<bhe@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>, Mark Salter
	<msalter@...hat.com>, Aleksey Makarov <aleksey.makarov@...aro.org>, Kees Cook
	<keescook@...omium.org>, Andrew Morton <akpm@...ux-foundation.org>, Christian
 Borntraeger <borntraeger@...ibm.com>, Fabian Frederick <fabf@...net.be>,
	Toshi Kani <toshi.kani@...com>, Dan Williams <dan.j.williams@...el.com>
CC: <x86@...nel.org>, <linux-kernel@...r.kernel.org>,
	<kernel-hardening@...ts.openwall.com>
Subject: Re: [PATCH v1 2/2] x86/KASLR: Increase BRK pages for KASLR memory
 randomization

On 08/08/2016 09:40 PM, Thomas Garnier wrote:
> Default implementation expects 6 pages maximum are needed for low page
> allocations. If KASLR memory randomization is enabled, the worse case
> of e820 layout would require 12 pages (no large pages). It is due to the
> PUD level randomization and the variable e820 memory layout.
> 
> This bug was found while doing extensive testing of KASLR memory
> randomization on different type of hardware.
> 
> Signed-off-by: Thomas Garnier <thgarnie@...gle.com>
> ---
> Based on next-20160805
> ---
>  arch/x86/mm/init.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> index 6209289..3a27e6a 100644
> --- a/arch/x86/mm/init.c
> +++ b/arch/x86/mm/init.c
> @@ -130,6 +130,14 @@ void  __init early_alloc_pgt_buf(void)
>  	unsigned long tables = INIT_PGT_BUF_SIZE;
>  	phys_addr_t base;
>  
> +	/*
> +	 * Depending on the machine e860 memory layout and the PUD alignement.
> +	 * We may need twice more pages when KASLR memoy randomization is
> +	 * enabled.
> +	 */
> +	if (IS_ENABLED(CONFIG_RANDOMIZE_MEMORY))
> +		tables *= 2;
> +
>  	base = __pa(extend_brk(tables, PAGE_SIZE));
>  
>  	pgt_buf_start = base >> PAGE_SHIFT;
> 

You should increase the reserve also :
RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE);


--Mika

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.