]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mm: introduce VM_POPULATE flag to better deal with racy userspace programs
authorMichel Lespinasse <walken@google.com>
Thu, 7 Feb 2013 01:26:20 +0000 (12:26 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:46:21 +0000 (16:46 +1100)
commit94e71f6d4d370fa46d9f2186e209023b89d2dbe8
treea996a93084e10768a66b02d46605f6ba32208933
parent9a17d55ca4d155c0446312c2471ca17f779ccfc7
mm: introduce VM_POPULATE flag to better deal with racy userspace programs

The vm_populate() code populates user mappings without constantly
holding the mmap_sem. This makes it susceptible to racy userspace
programs: the user mappings may change while vm_populate() is running,
and in this case vm_populate() may end up populating the new mapping
instead of the old one.

In order to reduce the possibility of userspace getting surprised by
this behavior, this change introduces the VM_POPULATE vma flag which
gets set on vmas we want vm_populate() to work on. This way
vm_populate() may still end up populating the new mapping after such a
race, but only if the new mapping is also one that the user has
requested (using MAP_SHARED, MAP_LOCKED or mlock) to be populated.

Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Tested-by: Andy Lutomirski <luto@amacapital.net>
Cc: Greg Ungerer <gregungerer@westnet.com.au>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
include/linux/mman.h
mm/fremap.c
mm/mlock.c
mm/mmap.c