Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-13 Thread Michal Hocko
On Wed 13-12-17 04:50:53, Matthew Wilcox wrote: > On Wed, Dec 13, 2017 at 10:25:49AM +0100, Michal Hocko wrote: > > +++ b/mm/mmap.c > > @@ -1342,6 +1342,10 @@ unsigned long do_mmap(struct file *file, unsigned > > long addr, > > if (!(file && path_noexec(>f_path))) > >

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-13 Thread Michal Hocko
On Wed 13-12-17 04:50:53, Matthew Wilcox wrote: > On Wed, Dec 13, 2017 at 10:25:49AM +0100, Michal Hocko wrote: > > +++ b/mm/mmap.c > > @@ -1342,6 +1342,10 @@ unsigned long do_mmap(struct file *file, unsigned > > long addr, > > if (!(file && path_noexec(>f_path))) > >

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-13 Thread Matthew Wilcox
On Wed, Dec 13, 2017 at 10:25:49AM +0100, Michal Hocko wrote: > +++ b/mm/mmap.c > @@ -1342,6 +1342,10 @@ unsigned long do_mmap(struct file *file, unsigned long > addr, > if (!(file && path_noexec(>f_path))) > prot |= PROT_EXEC; > > + /* force arch

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-13 Thread Matthew Wilcox
On Wed, Dec 13, 2017 at 10:25:49AM +0100, Michal Hocko wrote: > +++ b/mm/mmap.c > @@ -1342,6 +1342,10 @@ unsigned long do_mmap(struct file *file, unsigned long > addr, > if (!(file && path_noexec(>f_path))) > prot |= PROT_EXEC; > > + /* force arch

[PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-13 Thread Michal Hocko
From: Michal Hocko MAP_FIXED is used quite often to enforce mapping at the particular range. The main problem of this flag is, however, that it is inherently dangerous because it unmaps existing mappings covered by the requested range. This can cause silent memory corruptions.

[PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-13 Thread Michal Hocko
From: Michal Hocko MAP_FIXED is used quite often to enforce mapping at the particular range. The main problem of this flag is, however, that it is inherently dangerous because it unmaps existing mappings covered by the requested range. This can cause silent memory corruptions. Some of them even

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-07 Thread Pavel Machek
Hi! > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing mappings covered by the requested > range. This can cause silent memory corruptions. Some of them even with >

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-07 Thread Pavel Machek
Hi! > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing mappings covered by the requested > range. This can cause silent memory corruptions. Some of them even with >

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-06 Thread Michal Hocko
On Wed 06-12-17 10:27:24, Michal Hocko wrote: > On Wed 06-12-17 16:15:24, Michael Ellerman wrote: [...] > > So I think I proved above that all the arches that are using 0x8 are > > also using mman-common.h, and vice-versa. > > > > So you can put this in mman-common.h can't your? > > Yes it

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-06 Thread Michal Hocko
On Wed 06-12-17 10:27:24, Michal Hocko wrote: > On Wed 06-12-17 16:15:24, Michael Ellerman wrote: [...] > > So I think I proved above that all the arches that are using 0x8 are > > also using mman-common.h, and vice-versa. > > > > So you can put this in mman-common.h can't your? > > Yes it

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-06 Thread Michal Hocko
On Wed 06-12-17 16:15:24, Michael Ellerman wrote: > Hi Michal, > > Some comments below. > > Michal Hocko writes: > > > From: Michal Hocko > > > > MAP_FIXED is used quite often to enforce mapping at the particular > > range. The main problem of this flag is,

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-06 Thread Michal Hocko
On Wed 06-12-17 16:15:24, Michael Ellerman wrote: > Hi Michal, > > Some comments below. > > Michal Hocko writes: > > > From: Michal Hocko > > > > MAP_FIXED is used quite often to enforce mapping at the particular > > range. The main problem of this flag is, however, that it is inherently > >

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-05 Thread Michael Ellerman
Hi Michal, Some comments below. Michal Hocko writes: > From: Michal Hocko > > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing

Re: [PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-12-05 Thread Michael Ellerman
Hi Michal, Some comments below. Michal Hocko writes: > From: Michal Hocko > > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing mappings covered by the requested >

[PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-29 Thread Michal Hocko
From: Michal Hocko MAP_FIXED is used quite often to enforce mapping at the particular range. The main problem of this flag is, however, that it is inherently dangerous because it unmaps existing mappings covered by the requested range. This can cause silent memory corruptions.

[PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-29 Thread Michal Hocko
From: Michal Hocko MAP_FIXED is used quite often to enforce mapping at the particular range. The main problem of this flag is, however, that it is inherently dangerous because it unmaps existing mappings covered by the requested range. This can cause silent memory corruptions. Some of them even

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Florian Weimer
On 11/20/2017 10:33 AM, Michal Hocko wrote: On Mon 20-11-17 10:10:32, Florian Weimer wrote: On 11/20/2017 09:55 AM, Michal Hocko wrote: On Fri 17-11-17 08:30:48, Florian Weimer wrote: On 11/16/2017 11:18 AM, Michal Hocko wrote: + if (flags & MAP_FIXED_SAFE) { + struct

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Florian Weimer
On 11/20/2017 10:33 AM, Michal Hocko wrote: On Mon 20-11-17 10:10:32, Florian Weimer wrote: On 11/20/2017 09:55 AM, Michal Hocko wrote: On Fri 17-11-17 08:30:48, Florian Weimer wrote: On 11/16/2017 11:18 AM, Michal Hocko wrote: + if (flags & MAP_FIXED_SAFE) { + struct

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Mon 20-11-17 10:10:32, Florian Weimer wrote: > On 11/20/2017 09:55 AM, Michal Hocko wrote: > > On Fri 17-11-17 08:30:48, Florian Weimer wrote: > > > On 11/16/2017 11:18 AM, Michal Hocko wrote: > > > > + if (flags & MAP_FIXED_SAFE) { > > > > + struct vm_area_struct *vma =

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Mon 20-11-17 10:10:32, Florian Weimer wrote: > On 11/20/2017 09:55 AM, Michal Hocko wrote: > > On Fri 17-11-17 08:30:48, Florian Weimer wrote: > > > On 11/16/2017 11:18 AM, Michal Hocko wrote: > > > > + if (flags & MAP_FIXED_SAFE) { > > > > + struct vm_area_struct *vma =

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Florian Weimer
On 11/20/2017 09:55 AM, Michal Hocko wrote: On Fri 17-11-17 08:30:48, Florian Weimer wrote: On 11/16/2017 11:18 AM, Michal Hocko wrote: + if (flags & MAP_FIXED_SAFE) { + struct vm_area_struct *vma = find_vma(mm, addr); + + if (vma && vma->vm_start <= addr) +

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Florian Weimer
On 11/20/2017 09:55 AM, Michal Hocko wrote: On Fri 17-11-17 08:30:48, Florian Weimer wrote: On 11/16/2017 11:18 AM, Michal Hocko wrote: + if (flags & MAP_FIXED_SAFE) { + struct vm_area_struct *vma = find_vma(mm, addr); + + if (vma && vma->vm_start <= addr) +

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Fri 17-11-17 00:37:18, John Hubbard wrote: > On 11/16/2017 02:18 AM, Michal Hocko wrote: [...] > > diff --git a/arch/powerpc/include/uapi/asm/mman.h > > b/arch/powerpc/include/uapi/asm/mman.h > > index 03c06ba7464f..d97342ca25b1 100644 > > --- a/arch/powerpc/include/uapi/asm/mman.h > > +++

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Fri 17-11-17 00:37:18, John Hubbard wrote: > On 11/16/2017 02:18 AM, Michal Hocko wrote: [...] > > diff --git a/arch/powerpc/include/uapi/asm/mman.h > > b/arch/powerpc/include/uapi/asm/mman.h > > index 03c06ba7464f..d97342ca25b1 100644 > > --- a/arch/powerpc/include/uapi/asm/mman.h > > +++

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Fri 17-11-17 08:30:48, Florian Weimer wrote: > On 11/16/2017 11:18 AM, Michal Hocko wrote: > > + if (flags & MAP_FIXED_SAFE) { > > + struct vm_area_struct *vma = find_vma(mm, addr); > > + > > + if (vma && vma->vm_start <= addr) > > + return -ENOMEM; > > +

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Fri 17-11-17 08:30:48, Florian Weimer wrote: > On 11/16/2017 11:18 AM, Michal Hocko wrote: > > + if (flags & MAP_FIXED_SAFE) { > > + struct vm_area_struct *vma = find_vma(mm, addr); > > + > > + if (vma && vma->vm_start <= addr) > > + return -ENOMEM; > > +

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Fri 17-11-17 11:12:51, Matthew Wilcox wrote: > On Thu, Nov 16, 2017 at 04:27:36PM -0800, Kees Cook wrote: > > On Thu, Nov 16, 2017 at 2:18 AM, Michal Hocko wrote: > > > From: Michal Hocko > > > > > > MAP_FIXED is used quite often to enforce mapping at the

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-20 Thread Michal Hocko
On Fri 17-11-17 11:12:51, Matthew Wilcox wrote: > On Thu, Nov 16, 2017 at 04:27:36PM -0800, Kees Cook wrote: > > On Thu, Nov 16, 2017 at 2:18 AM, Michal Hocko wrote: > > > From: Michal Hocko > > > > > > MAP_FIXED is used quite often to enforce mapping at the particular > > > range. The main

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-17 Thread Matthew Wilcox
On Thu, Nov 16, 2017 at 04:27:36PM -0800, Kees Cook wrote: > On Thu, Nov 16, 2017 at 2:18 AM, Michal Hocko wrote: > > From: Michal Hocko > > > > MAP_FIXED is used quite often to enforce mapping at the particular > > range. The main problem of this flag is,

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-17 Thread Matthew Wilcox
On Thu, Nov 16, 2017 at 04:27:36PM -0800, Kees Cook wrote: > On Thu, Nov 16, 2017 at 2:18 AM, Michal Hocko wrote: > > From: Michal Hocko > > > > MAP_FIXED is used quite often to enforce mapping at the particular > > range. The main problem of this flag is, however, that it is inherently > >

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-17 Thread John Hubbard
On 11/16/2017 02:18 AM, Michal Hocko wrote: > From: Michal Hocko > > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing mappings covered by the

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-17 Thread John Hubbard
On 11/16/2017 02:18 AM, Michal Hocko wrote: > From: Michal Hocko > > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing mappings covered by the requested > range. This

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-16 Thread Florian Weimer
On 11/16/2017 11:18 AM, Michal Hocko wrote: + if (flags & MAP_FIXED_SAFE) { + struct vm_area_struct *vma = find_vma(mm, addr); + + if (vma && vma->vm_start <= addr) + return -ENOMEM; + } Could you pick a different error code which

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-16 Thread Florian Weimer
On 11/16/2017 11:18 AM, Michal Hocko wrote: + if (flags & MAP_FIXED_SAFE) { + struct vm_area_struct *vma = find_vma(mm, addr); + + if (vma && vma->vm_start <= addr) + return -ENOMEM; + } Could you pick a different error code which

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-16 Thread Kees Cook
On Thu, Nov 16, 2017 at 2:18 AM, Michal Hocko wrote: > From: Michal Hocko > > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing

Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-16 Thread Kees Cook
On Thu, Nov 16, 2017 at 2:18 AM, Michal Hocko wrote: > From: Michal Hocko > > MAP_FIXED is used quite often to enforce mapping at the particular > range. The main problem of this flag is, however, that it is inherently > dangerous because it unmaps existing mappings covered by the requested >

[RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-16 Thread Michal Hocko
From: Michal Hocko MAP_FIXED is used quite often to enforce mapping at the particular range. The main problem of this flag is, however, that it is inherently dangerous because it unmaps existing mappings covered by the requested range. This can cause silent memory corruptions.

[RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-16 Thread Michal Hocko
From: Michal Hocko MAP_FIXED is used quite often to enforce mapping at the particular range. The main problem of this flag is, however, that it is inherently dangerous because it unmaps existing mappings covered by the requested range. This can cause silent memory corruptions. Some of them even