]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit59ee9c6ee022899cd87df6f8cee1cd561866af8c
treefe3609c5e750d4a06876f61ab217503e56b4e182
parent1ee3ac3a39dfc495f94379f2a2badd619efdc68d
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