lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Jun 2014 17:33:11 +0400
From:	Vladimir Davydov <vdavydov@...allels.com>
To:	<akpm@...ux-foundation.org>
CC:	<oleg@...hat.com>, <rientjes@...gle.com>, <cl@...ux.com>,
	<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] fork: dup_mm: init vm stat 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 stats (total_vm and
friends) screwed up, because currently they are copied from oldmm w/o
holding any locks (see dup_mm).

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

Also, mm->pinned_vm is not reset on fork. Let's fix it.

Signed-off-by: Vladimir Davydov <vdavydov@...allels.com>
---
 kernel/fork.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index d2799d1fc952..eaacc75da4f7 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -365,7 +365,12 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
 	 */
 	down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
 
+	mm->total_vm = oldmm->total_vm;
 	mm->locked_vm = 0;
+	mm->pinned_vm = 0;
+	mm->shared_vm = oldmm->shared_vm;
+	mm->exec_vm = oldmm->exec_vm;
+	mm->stack_vm = oldmm->stack_vm;
 	mm->mmap = NULL;
 	mm->vmacache_seqnum = 0;
 	mm->map_count = 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ