login
Header Space

 
 

Re: 2.6.23-rc6-mm1 - make access to tasks nsproxy ligther (fix)

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Cedric Le Goater <clg@...>
Cc: Pavel Emelyanov <xemul@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, Serge E. Hallyn <serue@...>, Eric W. Biederman <ebiederm@...>, Oleg Nesterov <oleg@...>, Paul E. McKenney <paulmck@...>
Date: Thursday, September 20, 2007 - 1:08 pm

Cedric Le Goater wrote:

So I removed this test in

* daemonize() bc it is already done 
* sys_unshare() bc the nsproxy is always new one 
* exit_task_namespaces() bc it is called with NULL and the
  task will die right after that.

C.


make-access-to-tasks-nsproxy-lighter.patch breaks unshare()

when called from unshare(), switch_task_namespaces() takes an 
extra refcount on the nsproxy, leading to a memory leak of 
nsproxy objects. 

Now the problem is that we still need that extra ref when called 
from daemonize(). Here's an ugly fix for it.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Cc: Serge E. Hallyn <serue@us.ibm.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

---
 include/linux/nsproxy.h |    5 +++++
 kernel/exit.c           |    5 ++++-
 kernel/nsproxy.c        |    9 ---------
 3 files changed, 9 insertions(+), 10 deletions(-)

Index: 2.6.23-rc6-mm1/kernel/nsproxy.c
===================================================================
--- 2.6.23-rc6-mm1.orig/kernel/nsproxy.c
+++ 2.6.23-rc6-mm1/kernel/nsproxy.c
@@ -25,11 +25,6 @@ static struct kmem_cache *nsproxy_cachep
 
 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
 
-static inline void get_nsproxy(struct nsproxy *ns)
-{
-	atomic_inc(&ns->count);
-}
-
 /*
  * creates a copy of "orig" with refcount 1.
  */
@@ -205,11 +200,7 @@ void switch_task_namespaces(struct task_
 	might_sleep();
 
 	ns = p->nsproxy;
-	if (ns == new)
-		return;
 
-	if (new)
-		get_nsproxy(new);
 	rcu_assign_pointer(p->nsproxy, new);
 
 	if (ns && atomic_dec_and_test(&ns->count)) {
Index: 2.6.23-rc6-mm1/kernel/exit.c
===================================================================
--- 2.6.23-rc6-mm1.orig/kernel/exit.c
+++ 2.6.23-rc6-mm1/kernel/exit.c
@@ -408,7 +408,10 @@ void daemonize(const char *name, ...)
 	current->fs = fs;
 	atomic_inc(&fs->count);
 
-	switch_task_namespaces(current, init_task.nsproxy);
+	if (current->nsproxy != init_task.nsproxy) {
+		get_nsproxy(init_task.nsproxy);
+		switch_task_namespaces(current, init_task.nsproxy);
+	}
 
 	exit_files(current);
 	current->files = init_task.files;
Index: 2.6.23-rc6-mm1/include/linux/nsproxy.h
===================================================================
--- 2.6.23-rc6-mm1.orig/include/linux/nsproxy.h
+++ 2.6.23-rc6-mm1/include/linux/nsproxy.h
@@ -77,6 +77,11 @@ static inline void put_nsproxy(struct ns
 	}
 }
 
+static inline void get_nsproxy(struct nsproxy *ns)
+{
+	atomic_inc(&ns->count);
+}
+
 #ifdef CONFIG_CONTAINER_NS
 int ns_container_clone(struct task_struct *tsk);
 #else
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.23-rc6-mm1, Andrew Morton, (Tue Sep 18, 4:18 am)
[PATCH -mm] iseries_veth: Kill unused variable, Satyam Sharma, (Sat Sep 22, 3:55 am)
Re: [PATCH] Remove broken netfilter binary sysctls from brid..., Eric W. Biederman, (Fri Sep 21, 12:21 am)
Re: [PATCH] Remove broken netfilter binary sysctls from brid..., Eric W. Biederman, (Tue Sep 25, 10:03 am)
Re: [PATCH] Remove broken netfilter binary sysctls from brid..., Eric W. Biederman, (Tue Sep 25, 12:38 pm)
Re: [PATCH] Remove broken netfilter binary sysctls from brid..., Stephen Hemminger, (Mon Sep 24, 4:14 pm)
Re: [PATCH] Remove broken netfilter binary sysctls from brid..., Stephen Hemminger, (Tue Sep 25, 12:12 pm)
Build failure on ppc64 drivers/block/ps3disk.c, Mel Gorman, (Thu Sep 20, 9:25 am)
2.6.23-rc6-mm1: Build failures on ppc64_defconfig, Satyam Sharma, (Thu Sep 20, 9:37 am)
Re: 2.6.23-rc6-mm1: Build failures on ppc64_defconfig, Satyam Sharma, (Sat Sep 22, 3:25 am)
Re: 2.6.23-rc6-mm1: Build failures on ppc64_defconfig, Satyam Sharma, (Sat Sep 22, 2:54 am)
Re: 2.6.23-rc6-mm1: Build failures on ppc64_defconfig, Satyam Sharma, (Sat Sep 22, 2:51 am)
Re: 2.6.23-rc6-mm1: Build failures on ppc64_defconfig, Satyam Sharma, (Sat Sep 22, 2:50 am)
Re: Build failure on ppc64 drivers/block/ps3disk.c, Jens Axboe, (Thu Sep 20, 9:32 am)
Re: 2.6.23-rc6-mm1: Build failure on ppc64 drivers/ata/pata_..., Kamalesh Babulal, (Thu Sep 20, 11:45 am)
Re: 2.6.23-rc6-mm1 - make access to tasks nsproxy ligther (f..., Cedric Le Goater, (Thu Sep 20, 1:08 pm)
Re: 2.6.23-rc6-mm1, Joseph Fannin, (Wed Sep 19, 7:58 pm)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Wed Sep 19, 8:09 pm)
Re: 2.6.23-rc6-mm1, Tilman Schmidt, (Wed Sep 19, 7:02 pm)
Re: 2.6.23-rc6-mm1, Tilman Schmidt, (Thu Sep 20, 3:20 pm)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Thu Sep 20, 4:25 pm)
Re: 2.6.23-rc6-mm1, Tilman Schmidt, (Thu Sep 20, 8:53 pm)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Wed Sep 19, 7:24 pm)
Re: 2.6.23-rc6-mm1, David Brownell, (Wed Sep 19, 7:44 pm)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Wed Sep 19, 8:06 pm)
Re: 2.6.23-rc6-mm1, David Brownell, (Thu Sep 20, 12:43 am)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Thu Sep 20, 2:11 am)
Re: 2.6.23-rc6-mm1, David Brownell, (Thu Sep 20, 1:36 pm)
Re: 2.6.23-rc6-mm1, Alessandro Zummo, (Thu Sep 20, 4:51 am)
Re: 2.6.23-rc6-mm1, Kay Sievers, (Thu Sep 20, 3:54 am)
Re: 2.6.23-rc6-mm1, David Brownell, (Thu Sep 20, 12:15 pm)
Re: 2.6.23-rc6-mm1, Chuck Ebbert, (Wed Sep 19, 7:28 pm)
Re: 2.6.23-rc6-mm1, Tilman Schmidt, (Wed Sep 19, 7:55 pm)
Re: 2.6.23-rc6-mm1, Tilman Schmidt, (Thu Sep 20, 3:10 pm)
2.6.23-rc6-mm1 -- mkfs stuck in 'D', Andy Whitcroft, (Wed Sep 19, 12:43 pm)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Hugh Dickins, (Wed Sep 19, 4:03 pm)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Peter Zijlstra, (Wed Sep 19, 4:44 pm)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Hugh Dickins, (Thu Sep 20, 7:31 am)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Fengguang Wu, (Fri Sep 21, 9:55 pm)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Peter Zijlstra, (Sat Sep 22, 9:16 am)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Fengguang Wu, (Sat Sep 22, 9:20 pm)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Peter Zijlstra, (Sun Sep 23, 9:02 am)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Fengguang Wu, (Sun Sep 23, 11:01 pm)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Peter Zijlstra, (Mon Sep 24, 3:35 am)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Fengguang Wu, (Mon Sep 24, 4:12 am)
Re: 2.6.23-rc6-mm1 -- mkfs stuck in 'D', Peter Zijlstra, (Thu Sep 20, 8:15 am)
X-freeze after clflush changes [Was: 2.6.23-rc6-mm1], Jiri Slaby, (Wed Sep 19, 7:43 am)
Re: X-freeze after clflush changes [Was: 2.6.23-rc6-mm1], Andrew Morton, (Wed Sep 19, 3:10 pm)
Re: X-freeze after clflush changes [Was: 2.6.23-rc6-mm1], Andrew Morton, (Wed Sep 19, 10:24 pm)
Re: X-freeze after clflush changes [Was: 2.6.23-rc6-mm1], Andrew Morton, (Wed Sep 19, 5:42 pm)
2.6.23-rc6-mm1 -- powerpc link failure, Andy Whitcroft, (Wed Sep 19, 5:28 am)
Re: 2.6.23-rc6-mm1 -- powerpc link failure, Sam Ravnborg, (Wed Sep 19, 1:44 pm)
Re: 2.6.23-rc6-mm1 -- powerpc link failure, Andy Whitcroft, (Tue Sep 25, 9:40 am)
Re: 2.6.23-rc6-mm1 -- powerpc link failure, Segher Boessenkool, (Wed Sep 19, 12:36 pm)
Re: 2.6.23-rc6-mm1 -- powerpc link failure, Andy Whitcroft, (Wed Sep 19, 12:52 pm)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Mariusz Kozlowski, (Tue Sep 18, 5:45 pm)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Cornelia Huck, (Wed Sep 19, 4:27 am)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Mariusz Kozlowski, (Wed Sep 19, 12:43 pm)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Cornelia Huck, (Wed Sep 19, 2:02 pm)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Cornelia Huck, (Thu Sep 20, 9:35 am)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Mariusz Kozlowski, (Thu Sep 20, 1:27 pm)
Re: 2.6.23-rc6-mm1: atomic counter underflow, Pierre Ossman, (Thu Sep 20, 12:30 pm)
Re: kobject: Temporarily save k_name on cleanup for debug me..., Mariusz Kozlowski, (Thu Sep 20, 1:26 pm)
Re: 2.6.23-rc6-mm1 sparc build error, Mathieu Desnoyers, (Tue Sep 18, 4:54 pm)
Re: 2.6.23-rc6-mm1 sparc build error, Andrew Morton, (Tue Sep 18, 5:05 pm)
Re: 2.6.23-rc6-mm1 sparc build error, Guennadi Liakhovetski, (Thu Sep 20, 8:53 am)
Re: 2.6.23-rc6-mm1 sparc build error, Mathieu Desnoyers, (Fri Sep 21, 9:51 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, Rafael J. Wysocki, (Tue Sep 18, 4:21 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, Rafael J. Wysocki, (Tue Sep 18, 4:54 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Tue Sep 18, 5:37 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Wed Sep 19, 1:44 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Wed Sep 19, 8:06 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 9:29 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 10:12 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 4:42 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 10:47 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 4:39 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Fri Sep 21, 5:25 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 6:30 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Fri Sep 21, 10:20 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Fri Sep 21, 3:20 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Fri Sep 21, 3:37 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 5:54 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 5:45 pm)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Fri Sep 21, 5:24 am)
Re: 2.6.23-rc6-mm1: failure to boot on HP nx6325, no sound w..., Rafael J. Wysocki, (Thu Sep 20, 6:35 pm)
Re: 2.6.23-rc6-mm1, Mel Gorman, (Tue Sep 18, 1:44 pm)
Re: 2.6.23-rc6-mm1, Satyam Sharma, (Sat Sep 22, 4:41 am)
Re: 2.6.23-rc6-mm1, Mel Gorman, (Mon Sep 24, 7:14 am)
2.6.23-rc6-mm1: kgdb support on ppc64 utterly broken, Mel Gorman, (Wed Sep 19, 12:29 pm)
Re: 2.6.23-rc6-mm1 (watchdog), Randy Dunlap, (Tue Sep 18, 1:18 pm)
Re: 2.6.23-rc6-mm1 (watchdog), Randy Dunlap, (Tue Sep 18, 1:41 pm)
Re: 2.6.23-rc6-mm1, Miles Lane, (Tue Sep 18, 1:20 pm)
Re: 2.6.23-rc6-mm1, Mel Gorman, (Tue Sep 18, 2:05 pm)
modpost errors ( Re: 2.6.23-rc6-mm1), Gabriel C, (Tue Sep 18, 11:43 am)
Re: modpost errors ( Re: 2.6.23-rc6-mm1), Sam Ravnborg, (Tue Sep 18, 11:56 am)
Re: [v4l-dvb-maintainer] modpost errors ( Re: 2.6.23-rc6-mm1), Mauro Carvalho Chehab, (Tue Sep 18, 6:06 pm)
Re: 2.6.23-rc6-mm1, Miles Lane, (Tue Sep 18, 11:27 am)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Tue Sep 18, 3:17 pm)
Re: 2.6.23-rc6-mm1, Miles Lane, (Tue Sep 18, 3:42 pm)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Tue Sep 18, 4:26 pm)
Re: 2.6.23-rc6-mm1, Gabriel C, (Tue Sep 18, 6:38 pm)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Wed Sep 19, 2:48 pm)
Re: 2.6.23-rc6-mm1, Gabriel C, (Tue Sep 18, 6:48 pm)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Wed Sep 19, 3:33 pm)
Re: 2.6.23-rc6-mm1, Gabriel C, (Wed Sep 19, 4:36 pm)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Wed Sep 19, 4:43 pm)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Tue Sep 18, 11:52 am)
Re: 2.6.23-rc6-mm1, Miles Lane, (Tue Sep 18, 11:39 am)
Re: 2.6.23-rc6-mm1, , (Tue Sep 18, 11:07 am)
Re: 2.6.23-rc6-mm1, Sam Ravnborg, (Tue Sep 18, 11:50 am)
Re: 2.6.23-rc6-mm1, Kamalesh Babulal, (Tue Sep 18, 5:13 am)
Re: 2.6.23-rc6-mm1, Andy Whitcroft, (Tue Sep 18, 5:34 am)
Re: 2.6.23-rc6-mm1, Benjamin Herrenschmidt, (Tue Sep 18, 6:02 am)
Re: 2.6.23-rc6-mm1, Kamalesh Babulal, (Tue Sep 18, 8:07 am)
Re: 2.6.23-rc6-mm1, Greg KH, (Tue Sep 18, 3:16 pm)
Re: 2.6.23-rc6-mm1, Benjamin Herrenschmidt, (Tue Sep 18, 5:35 pm)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Tue Sep 18, 12:53 pm)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Tue Sep 18, 5:27 am)
Re: 2.6.23-rc6-mm1, Satyam Sharma, (Tue Sep 18, 5:34 am)
Re: 2.6.23-rc6-mm1, Greg KH, (Tue Sep 18, 3:17 pm)
Re: 2.6.23-rc6-mm1, Satyam Sharma, (Sat Sep 22, 5:21 am)
Re: 2.6.23-rc6-mm1, Greg KH, (Tue Sep 25, 1:35 am)
Re: 2.6.23-rc6-mm1, Andrew Morton, (Tue Sep 18, 4:24 am)
speck-geostationary