public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix refcounting of nsproxy object when unshared
@ 2007-06-18 20:12 Cedric Le Goater
  0 siblings, 0 replies; only message in thread
From: Cedric Le Goater @ 2007-06-18 20:12 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Badari Pulavarty, Herbert Poetzl, Oleg Nesterov, Andrew Morton

When a namespace is unshared, a refcount on the previous nsproxy is
abusively taken, leading to a memory leak of nsproxy objects. 
 
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>

---
 kernel/nsproxy.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Index: 2.6.22-rc5/kernel/nsproxy.c
===================================================================
--- 2.6.22-rc5.orig/kernel/nsproxy.c
+++ 2.6.22-rc5/kernel/nsproxy.c
@@ -145,13 +145,11 @@ void free_nsproxy(struct nsproxy *ns)
 
 /*
  * Called from unshare. Unshare all the namespaces part of nsproxy.
- * On sucess, returns the new nsproxy and a reference to old nsproxy
- * to make sure it stays around.
+ * On success, returns the new nsproxy.
  */
 int unshare_nsproxy_namespaces(unsigned long unshare_flags,
 		struct nsproxy **new_nsp, struct fs_struct *new_fs)
 {
-	struct nsproxy *old_ns = current->nsproxy;
 	int err = 0;
 
 	if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
@@ -170,13 +168,9 @@ int unshare_nsproxy_namespaces(unsigned 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	get_nsproxy(old_ns);
-
 	*new_nsp = create_new_namespaces(unshare_flags, current,
 				new_fs ? new_fs : current->fs);
-	if (IS_ERR(*new_nsp)) {
+	if (IS_ERR(*new_nsp))
 		err = PTR_ERR(*new_nsp);
-		put_nsproxy(old_ns);
-	}
 	return err;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-18 20:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-18 20:12 [PATCH] fix refcounting of nsproxy object when unshared Cedric Le Goater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox