linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE)
@ 2017-08-14 15:57 Kirill A. Shutemov
  2017-08-14 16:13 ` Cyrill Gorcunov
  0 siblings, 1 reply; 6+ messages in thread
From: Kirill A. Shutemov @ 2017-08-14 15:57 UTC (permalink / raw)
  To: Linus Torvalds, x86, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
  Cc: Andrew Morton, Andy Lutomirski, Dmitry Safonov, Cyrill Gorcunov,
	Borislav Petkov, linux-mm, linux-kernel, Kirill A. Shutemov,
	stable

In v4.12, during rework of infrastructure around mmap_base, disable-ASLR
personality flag got accidentally broken.

Let's make it work again.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Fixes: 1b028f784e8c ("x86/mm: Introduce mmap_compat_base() for 32-bit mmap()")
Cc: stable <stable@vger.kernel.org> [4.12+]
---
 arch/x86/mm/mmap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 229d04a83f85..779bdbe5e424 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -127,6 +127,8 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
 static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
 		unsigned long random_factor, unsigned long task_size)
 {
+	if (!(current->flags & PF_RANDOMIZE))
+		random_factor = 0;
 	*legacy_base = mmap_legacy_base(random_factor, task_size);
 	if (mmap_is_legacy())
 		*base = *legacy_base;
-- 
2.14.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE)
  2017-08-14 15:57 [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE) Kirill A. Shutemov
@ 2017-08-14 16:13 ` Cyrill Gorcunov
  2017-08-14 16:20   ` Oleg Nesterov
  2017-08-14 16:22   ` Kirill A. Shutemov
  0 siblings, 2 replies; 6+ messages in thread
From: Cyrill Gorcunov @ 2017-08-14 16:13 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Linus Torvalds, x86, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, Andrew Morton, Andy Lutomirski, Dmitry Safonov,
	Borislav Petkov, linux-mm, linux-kernel, stable, Oleg Nesterov

On Mon, Aug 14, 2017 at 06:57:19PM +0300, Kirill A. Shutemov wrote:
> In v4.12, during rework of infrastructure around mmap_base, disable-ASLR
> personality flag got accidentally broken.
> 
> Let's make it work again.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Fixes: 1b028f784e8c ("x86/mm: Introduce mmap_compat_base() for 32-bit mmap()")
> Cc: stable <stable@vger.kernel.org> [4.12+]
> ---
>  arch/x86/mm/mmap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
> index 229d04a83f85..779bdbe5e424 100644
> --- a/arch/x86/mm/mmap.c
> +++ b/arch/x86/mm/mmap.c
> @@ -127,6 +127,8 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
>  static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
>  		unsigned long random_factor, unsigned long task_size)
>  {
> +	if (!(current->flags & PF_RANDOMIZE))
> +		random_factor = 0;
>  	*legacy_base = mmap_legacy_base(random_factor, task_size);
>  	if (mmap_is_legacy())
>  		*base = *legacy_base;

Didn't Oleg's patch does the same?

https://patchwork.kernel.org/patch/9832697/

for some reason it's not yet merged.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE)
  2017-08-14 16:13 ` Cyrill Gorcunov
@ 2017-08-14 16:20   ` Oleg Nesterov
  2017-08-14 16:26     ` Kirill A. Shutemov
  2017-08-14 16:28     ` Cyrill Gorcunov
  2017-08-14 16:22   ` Kirill A. Shutemov
  1 sibling, 2 replies; 6+ messages in thread
From: Oleg Nesterov @ 2017-08-14 16:20 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Kirill A. Shutemov, Linus Torvalds, x86, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Andrew Morton, Andy Lutomirski,
	Dmitry Safonov, Borislav Petkov, linux-mm, linux-kernel, stable

On 08/14, Cyrill Gorcunov wrote:
>
> On Mon, Aug 14, 2017 at 06:57:19PM +0300, Kirill A. Shutemov wrote:
> > In v4.12, during rework of infrastructure around mmap_base, disable-ASLR
> > personality flag got accidentally broken.
> >
> > Let's make it work again.
> > 
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Fixes: 1b028f784e8c ("x86/mm: Introduce mmap_compat_base() for 32-bit mmap()")
> > Cc: stable <stable@vger.kernel.org> [4.12+]
> > ---
> >  arch/x86/mm/mmap.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
> > index 229d04a83f85..779bdbe5e424 100644
> > --- a/arch/x86/mm/mmap.c
> > +++ b/arch/x86/mm/mmap.c
> > @@ -127,6 +127,8 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
> >  static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
> >  		unsigned long random_factor, unsigned long task_size)
> >  {
> > +	if (!(current->flags & PF_RANDOMIZE))
> > +		random_factor = 0;
> >  	*legacy_base = mmap_legacy_base(random_factor, task_size);
> >  	if (mmap_is_legacy())
> >  		*base = *legacy_base;
>
> Didn't Oleg's patch does the same?
>
> https://patchwork.kernel.org/patch/9832697/

at first glance yes, thanks Cyrill. And note that we do not need another
PF_RANDOMIZE check.

> for some reason it's not yet merged.

because nobody cares ;)

Oleg.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE)
  2017-08-14 16:13 ` Cyrill Gorcunov
  2017-08-14 16:20   ` Oleg Nesterov
@ 2017-08-14 16:22   ` Kirill A. Shutemov
  1 sibling, 0 replies; 6+ messages in thread
From: Kirill A. Shutemov @ 2017-08-14 16:22 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Kirill A. Shutemov, Linus Torvalds, x86, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Andrew Morton, Andy Lutomirski,
	Dmitry Safonov, Borislav Petkov, linux-mm, linux-kernel, stable,
	Oleg Nesterov

On Mon, Aug 14, 2017 at 07:13:47PM +0300, Cyrill Gorcunov wrote:
> On Mon, Aug 14, 2017 at 06:57:19PM +0300, Kirill A. Shutemov wrote:
> > In v4.12, during rework of infrastructure around mmap_base, disable-ASLR
> > personality flag got accidentally broken.
> > 
> > Let's make it work again.
> > 
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Fixes: 1b028f784e8c ("x86/mm: Introduce mmap_compat_base() for 32-bit mmap()")
> > Cc: stable <stable@vger.kernel.org> [4.12+]
> > ---
> >  arch/x86/mm/mmap.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
> > index 229d04a83f85..779bdbe5e424 100644
> > --- a/arch/x86/mm/mmap.c
> > +++ b/arch/x86/mm/mmap.c
> > @@ -127,6 +127,8 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
> >  static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
> >  		unsigned long random_factor, unsigned long task_size)
> >  {
> > +	if (!(current->flags & PF_RANDOMIZE))
> > +		random_factor = 0;
> >  	*legacy_base = mmap_legacy_base(random_factor, task_size);
> >  	if (mmap_is_legacy())
> >  		*base = *legacy_base;
> 
> Didn't Oleg's patch does the same?

Yes, it does. And it looks cleaner than my attempt.

> https://patchwork.kernel.org/patch/9832697/
> 
> for some reason it's not yet merged.

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE)
  2017-08-14 16:20   ` Oleg Nesterov
@ 2017-08-14 16:26     ` Kirill A. Shutemov
  2017-08-14 16:28     ` Cyrill Gorcunov
  1 sibling, 0 replies; 6+ messages in thread
From: Kirill A. Shutemov @ 2017-08-14 16:26 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Cyrill Gorcunov, Kirill A. Shutemov, Linus Torvalds, x86,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
	Andy Lutomirski, Dmitry Safonov, Borislav Petkov, linux-mm,
	linux-kernel, stable

On Mon, Aug 14, 2017 at 06:20:02PM +0200, Oleg Nesterov wrote:
> On 08/14, Cyrill Gorcunov wrote:
> >
> > On Mon, Aug 14, 2017 at 06:57:19PM +0300, Kirill A. Shutemov wrote:
> > > In v4.12, during rework of infrastructure around mmap_base, disable-ASLR
> > > personality flag got accidentally broken.
> > >
> > > Let's make it work again.
> > > 
> > > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > > Fixes: 1b028f784e8c ("x86/mm: Introduce mmap_compat_base() for 32-bit mmap()")
> > > Cc: stable <stable@vger.kernel.org> [4.12+]
> > > ---
> > >  arch/x86/mm/mmap.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
> > > index 229d04a83f85..779bdbe5e424 100644
> > > --- a/arch/x86/mm/mmap.c
> > > +++ b/arch/x86/mm/mmap.c
> > > @@ -127,6 +127,8 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
> > >  static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
> > >  		unsigned long random_factor, unsigned long task_size)
> > >  {
> > > +	if (!(current->flags & PF_RANDOMIZE))
> > > +		random_factor = 0;
> > >  	*legacy_base = mmap_legacy_base(random_factor, task_size);
> > >  	if (mmap_is_legacy())
> > >  		*base = *legacy_base;
> >
> > Didn't Oleg's patch does the same?
> >
> > https://patchwork.kernel.org/patch/9832697/
> 
> at first glance yes, thanks Cyrill. And note that we do not need another
> PF_RANDOMIZE check.
> 
> > for some reason it's not yet merged.
> 
> because nobody cares ;)

Well, I do. :)

It took me few days to track down where huge variablity in micro benchmark
results comes from. :/

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE)
  2017-08-14 16:20   ` Oleg Nesterov
  2017-08-14 16:26     ` Kirill A. Shutemov
@ 2017-08-14 16:28     ` Cyrill Gorcunov
  1 sibling, 0 replies; 6+ messages in thread
From: Cyrill Gorcunov @ 2017-08-14 16:28 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Kirill A. Shutemov, Linus Torvalds, x86, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Andrew Morton, Andy Lutomirski,
	Dmitry Safonov, Borislav Petkov, linux-mm, linux-kernel, stable

On Mon, Aug 14, 2017 at 06:20:02PM +0200, Oleg Nesterov wrote:
...
> >
> > Didn't Oleg's patch does the same?
> >
> > https://patchwork.kernel.org/patch/9832697/
> 
> at first glance yes, thanks Cyrill. And note that we do not need another
> PF_RANDOMIZE check.
> 
> > for some reason it's not yet merged.
> 
> because nobody cares ;)

We all care but people are busy ;) Anyway hopefully it get merged soon.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-14 16:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-14 15:57 [PATCH] x86/mm: Fix personality(ADDR_NO_RANDOMIZE) Kirill A. Shutemov
2017-08-14 16:13 ` Cyrill Gorcunov
2017-08-14 16:20   ` Oleg Nesterov
2017-08-14 16:26     ` Kirill A. Shutemov
2017-08-14 16:28     ` Cyrill Gorcunov
2017-08-14 16:22   ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox