Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-18 Thread Thomas Gleixner
On Fri, 14 Nov 2014, Kees Cook wrote: > On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: > > On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: > >> On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: > >>> v2: > >>> - added call to free_init_pages(), as suggested by tglx > > > >> something

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-18 Thread Thomas Gleixner
On Fri, 14 Nov 2014, Kees Cook wrote: On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook keesc...@chromium.org wrote: v2: - added call to

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Yinghai Lu
On Mon, Nov 17, 2014 at 12:27 PM, Kees Cook wrote: > On Sun, Nov 16, 2014 at 3:44 PM, Thomas Gleixner wrote: >> >> So the initial patch to get rid of the X mapping is of course to just >> extend the area to the PMD. A little bit different to your initial >> patch, but essentially the same. >> >>

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Kees Cook
On Mon, Nov 17, 2014 at 12:32 PM, Russell King - ARM Linux wrote: > On Mon, Nov 17, 2014 at 12:27:59PM -0800, Kees Cook wrote: >> I have a series for arm that is waiting to be picked up by rmk: >> https://patchwork.ozlabs.org/patch/400383/ > > It should've been in linux-next via my tree for the

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Russell King - ARM Linux
On Mon, Nov 17, 2014 at 12:27:59PM -0800, Kees Cook wrote: > I have a series for arm that is waiting to be picked up by rmk: > https://patchwork.ozlabs.org/patch/400383/ It should've been in linux-next via my tree for the last two weeks or so. -- FTTC broadband for 0.8mile line: currently at

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Kees Cook
On Sun, Nov 16, 2014 at 3:44 PM, Thomas Gleixner wrote: > On Fri, 14 Nov 2014, Kees Cook wrote: >> On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: >> > should use attached one instead. >> > >> > 1. should use _brk_end instead of , as we only use partial of >> >brk. >> > 2. [_brk_end,

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Kees Cook
On Sun, Nov 16, 2014 at 3:44 PM, Thomas Gleixner t...@linutronix.de wrote: On Fri, 14 Nov 2014, Kees Cook wrote: On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu ying...@kernel.org wrote: should use attached one instead. 1. should use _brk_end instead of end, as we only use partial of brk.

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Russell King - ARM Linux
On Mon, Nov 17, 2014 at 12:27:59PM -0800, Kees Cook wrote: I have a series for arm that is waiting to be picked up by rmk: https://patchwork.ozlabs.org/patch/400383/ It should've been in linux-next via my tree for the last two weeks or so. -- FTTC broadband for 0.8mile line: currently at

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Kees Cook
On Mon, Nov 17, 2014 at 12:32 PM, Russell King - ARM Linux li...@arm.linux.org.uk wrote: On Mon, Nov 17, 2014 at 12:27:59PM -0800, Kees Cook wrote: I have a series for arm that is waiting to be picked up by rmk: https://patchwork.ozlabs.org/patch/400383/ It should've been in linux-next via my

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-17 Thread Yinghai Lu
On Mon, Nov 17, 2014 at 12:27 PM, Kees Cook keesc...@chromium.org wrote: On Sun, Nov 16, 2014 at 3:44 PM, Thomas Gleixner t...@linutronix.de wrote: So the initial patch to get rid of the X mapping is of course to just extend the area to the PMD. A little bit different to your initial patch,

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Yinghai Lu
On Sun, Nov 16, 2014 at 3:44 PM, Thomas Gleixner wrote: > > _brk_end is adjusted at boot time via extend_brk() up to __brk_limit, > which is the same as _end. We usually do not use all of that space. So > it's expected that _brk_end < _end. > >> Is this correct? It sounded like tglx wanted the

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Yinghai Lu
On Sun, Nov 16, 2014 at 1:26 PM, Thomas Gleixner wrote: > On Sat, 15 Nov 2014, Yinghai Lu wrote: >> +static pmd_t *last_pmd; >> /* >> * The head.S code sets up the kernel high mapping: >> * >> @@ -408,9 +409,26 @@ void __init cleanup_highmap(void) >> continue; >> if

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Yinghai Lu
On Sun, Nov 16, 2014 at 10:52 AM, Thomas Gleixner wrote: >> > >> > Are you sure? For me, _brk_end isn't far enough: >> > >> > [1.475572] all_end: 0x82df5000 >> > [1.476736] _brk_end: 0x82dd6000 >> >> Yes. _brk_end should be small then &_end. > > Wrong. _brk_end can move up

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Thomas Gleixner
On Fri, 14 Nov 2014, Kees Cook wrote: > On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: > > should use attached one instead. > > > > 1. should use _brk_end instead of , as we only use partial of > >brk. > > 2. [_brk_end, pm_end) page range is already converted. aka > >is not wasted. >

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Thomas Gleixner
On Sat, 15 Nov 2014, Yinghai Lu wrote: > +static pmd_t *last_pmd; > /* > * The head.S code sets up the kernel high mapping: > * > @@ -408,9 +409,26 @@ void __init cleanup_highmap(void) > continue; > if (vaddr < (unsigned long) _text || vaddr > end) >

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Thomas Gleixner
On Fri, 14 Nov 2014, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook wrote: > > On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: > > >> should use attached one instead. > >> > >> 1. should use _brk_end instead of , as we only use partial of > >>brk. > >> 2. [_brk_end,

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Thomas Gleixner
On Fri, 14 Nov 2014, Yinghai Lu wrote: On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook keesc...@chromium.org wrote: On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu ying...@kernel.org wrote: should use attached one instead. 1. should use _brk_end instead of end, as we only use partial of

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Thomas Gleixner
On Sat, 15 Nov 2014, Yinghai Lu wrote: +static pmd_t *last_pmd; /* * The head.S code sets up the kernel high mapping: * @@ -408,9 +409,26 @@ void __init cleanup_highmap(void) continue; if (vaddr (unsigned long) _text || vaddr end) set_pmd(pmd,

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Thomas Gleixner
On Fri, 14 Nov 2014, Kees Cook wrote: On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu ying...@kernel.org wrote: should use attached one instead. 1. should use _brk_end instead of end, as we only use partial of brk. 2. [_brk_end, pm_end) page range is already converted. aka is not

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Yinghai Lu
On Sun, Nov 16, 2014 at 10:52 AM, Thomas Gleixner t...@linutronix.de wrote: Are you sure? For me, _brk_end isn't far enough: [1.475572] all_end: 0x82df5000 [1.476736] _brk_end: 0x82dd6000 Yes. _brk_end should be small then _end. Wrong. _brk_end can move up to

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Yinghai Lu
On Sun, Nov 16, 2014 at 1:26 PM, Thomas Gleixner t...@linutronix.de wrote: On Sat, 15 Nov 2014, Yinghai Lu wrote: +static pmd_t *last_pmd; /* * The head.S code sets up the kernel high mapping: * @@ -408,9 +409,26 @@ void __init cleanup_highmap(void) continue; if

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-16 Thread Yinghai Lu
On Sun, Nov 16, 2014 at 3:44 PM, Thomas Gleixner t...@linutronix.de wrote: _brk_end is adjusted at boot time via extend_brk() up to __brk_limit, which is the same as _end. We usually do not use all of that space. So it's expected that _brk_end _end. Is this correct? It sounded like tglx

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-15 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 7:38 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook wrote: >> Is this correct? It sounded like tglx wanted the pmd split, like this: >> >> 0x8220-0x82c010M RW PSE GLB NX pmd >> 0x82c0-0x82df5000

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-15 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 7:38 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook keesc...@chromium.org wrote: Is this correct? It sounded like tglx wanted the pmd split, like this: 0x8220-0x82c010M RW PSE GLB NX pmd

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook wrote: > On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: >> should use attached one instead. >> >> 1. should use _brk_end instead of , as we only use partial of >>brk. >> 2. [_brk_end, pm_end) page range is already converted. aka >>is not

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 7:06 PM, Kees Cook wrote: > On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: >> >> [0.00] .text: [0x0100-0x0200d548] >> [0.00] .rodata: [0x0220-0x02a1cfff] >> [0.00] .data: [0x02c0-0x02e50e7f] >> [0.00] .init:

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Kees Cook
On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: >> When setting up permissions on kernel memory at boot, the end of the >> PMD that was split from bss remained executable. It should be NX like >> the rest. This performs a PMD alignment

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Kees Cook
On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: >> On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: >>> v2: >>> - added call to free_init_pages(), as suggested by tglx > >> something is wrong: >> >> [7.842479] Freeing unused kernel

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: >> v2: >> - added call to free_init_pages(), as suggested by tglx > something is wrong: > > [7.842479] Freeing unused kernel memory: 3844K (82e52000 - > 83213000) > [

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: > When setting up permissions on kernel memory at boot, the end of the > PMD that was split from bss remained executable. It should be NX like > the rest. This performs a PMD alignment instead of a PAGE alignment to > get the correct span of

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook keesc...@chromium.org wrote: When setting up permissions on kernel memory at boot, the end of the PMD that was split from bss remained executable. It should be NX like the rest. This performs a PMD alignment instead of a PAGE alignment to get the

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook keesc...@chromium.org wrote: v2: - added call to free_init_pages(), as suggested by tglx something is wrong: [7.842479] Freeing unused kernel memory: 3844K

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Kees Cook
On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook keesc...@chromium.org wrote: v2: - added call to free_init_pages(), as suggested by tglx something is

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Kees Cook
On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu ying...@kernel.org wrote: On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook keesc...@chromium.org wrote: When setting up permissions on kernel memory at boot, the end of the PMD that was split from bss remained executable. It should be NX like the rest.

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 7:06 PM, Kees Cook keesc...@chromium.org wrote: On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu ying...@kernel.org wrote: [0.00] .text: [0x0100-0x0200d548] [0.00] .rodata: [0x0220-0x02a1cfff] [0.00] .data: [0x02c0-0x02e50e7f] [

Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

2014-11-14 Thread Yinghai Lu
On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook keesc...@chromium.org wrote: On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu ying...@kernel.org wrote: should use attached one instead. 1. should use _brk_end instead of end, as we only use partial of brk. 2. [_brk_end, pm_end) page range is already