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>] [day] [month] [year] [list]
Message-ID: <20080706152223.GA2825@tv-sign.ru>
Date:	Sun, 6 Jul 2008 19:22:23 +0400
From:	Oleg Nesterov <oleg@...sign.ru>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Roland McGrath <roland@...hat.com>, linux-kernel@...r.kernel.org
Subject: [PATCH 4/4] coredump: turn core_state->nr_threads into atomic_t

Turn core_state->nr_threads into atomic_t and kill now unneeded
down_write(&mm->mmap_sem) in exit_mm().

Signed-off-by: Oleg Nesterov <oleg@...sign.ru>

 include/linux/mm_types.h |    2 +-
 kernel/exit.c            |    5 ++---
 fs/exec.c                |    2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

--- 26-rc2/include/linux/mm_types.h~4_NR_ATOMIC	2008-06-15 15:26:29.000000000 +0400
+++ 26-rc2/include/linux/mm_types.h	2008-06-16 18:00:08.000000000 +0400
@@ -160,7 +160,7 @@ struct vm_area_struct {
 };
 
 struct core_state {
-	int nr_threads;
+	atomic_t nr_threads;
 	struct completion startup;
 };
 
--- 26-rc2/kernel/exit.c~4_NR_ATOMIC	2008-06-15 15:28:21.000000000 +0400
+++ 26-rc2/kernel/exit.c	2008-07-06 18:10:12.000000000 +0400
@@ -667,10 +667,9 @@ static void exit_mm(struct task_struct *
 	down_read(&mm->mmap_sem);
 	if (mm->core_state) {
 		up_read(&mm->mmap_sem);
-		down_write(&mm->mmap_sem);
-		if (!--mm->core_state->nr_threads)
+
+		if (atomic_dec_and_test(&mm->core_state->nr_threads))
 			complete(&mm->core_state->startup);
-		up_write(&mm->mmap_sem);
 
 		wait_for_completion(&mm->core_done);
 		down_read(&mm->mmap_sem);
--- 26-rc2/fs/exec.c~4_NR_ATOMIC	2008-07-06 17:43:14.000000000 +0400
+++ 26-rc2/fs/exec.c	2008-07-06 18:12:33.000000000 +0400
@@ -1586,7 +1586,7 @@ static inline int zap_threads(struct tas
 	}
 	rcu_read_unlock();
 done:
-	core_state->nr_threads = nr;
+	atomic_set(&core_state->nr_threads, nr);
 	return nr;
 }
 

--
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