fork: copy mm's vm usage counters under mmap_sem
authorVladimir Davydov <vdavydov@parallels.com>
Fri, 8 Aug 2014 21:22:01 +0000 (14:22 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Aug 2014 22:57:23 +0000 (15:57 -0700)
commit4f7d461433bb4a4deee61baefdac6cd1a1ecb546
treefe3609c5e750d4a06876f61ab217503e56b4e182
parentce65cefa5debefc0e81d0a533bda467f0aa67350
fork: copy mm's vm usage counters under mmap_sem

If a forking process has a thread calling (un)mmap (silly but still),
the child process may have some of its mm's vm usage counters (total_vm
and friends) screwed up, because currently they are copied from oldmm
w/o holding any locks (memcpy in dup_mm).

This patch moves the counters initialization to dup_mmap() to be called
under oldmm->mmap_sem, which eliminates any possibility of race.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Christoph Lameter <cl@linux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/fork.c
This page took 0.026073 seconds and 5 git commands to generate.