nsproxy: Fix ->nsproxy counting problem in copy_namespace.
PATCH 1/1 nsproxy: Fix ->nsproxy counting problem in copy_namespace.
Quoted 1 line
From
cd41495e25cf2641ffe9e01a40d3d221a46b08beMon Sep 17 00:00:00 2001
From: Rakib Mullick <[email protected]>
Date: Thu, 7 Mar 2013 14:52:20 +0600
Subject: [PATCH] nsproxy: Fix ->nsproxy counting problem in copy_namespace.
In copy_namespace(), get_nsproxy() (which increments nsproxy->count) is called before checking namespace related flags. Therefore, task's nsproxy->count could have improper value, which could lead to calling free_nsproxy unnecessarily. Also, incrementing nsproxy->count is an atomic operation (which is expensive than normal increment operation), so before doing it - it's better we make sure namespace related flags are set.
--- kernel/nsproxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/nsproxy.c +2 -2
@@ -130,12 +130,12 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)if (!old_ns)return 0 ; -get_nsproxy (old_ns); -if (!(flags & (CLONE_NEWNS |CLONE_NEWUTS |CLONE_NEWIPC |CLONE_NEWPID |CLONE_NEWNET )))return 0 ; +get_nsproxy (old_ns); +if (!ns_capable (user_ns,CAP_SYS_ADMIN )) { err = -EPERM ; goto out;
Signature · 1 line
1.7.11.7
Eric W. Biederman
AppliedThanks applied.
This is an unpleasant accidental memory leak.
Eric
Quoted 34 lines · Rakib Mullick
From
cd41495e25cf2641ffe9e01a40d3d221a46b08beMon Sep 17 00:00:00 2001
From: Rakib Mullick <[email protected]>
Date: Thu, 7 Mar 2013 14:52:20 +0600
Subject: [PATCH] nsproxy: Fix ->nsproxy counting problem incopy_namespace.In
copy_namespace(),get_nsproxy()(which incrementsnsproxy->count) is called before checking namespace related flags. Therefore, task'snsproxy->countcould have improper value, which could lead to callingfree_nsproxyunnecessarily. Also, incrementingnsproxy->countis an atomic operation (which is expensive than normal increment operation), so before doing it - it's better we make sure namespace related flags are set.Signed-off-by Rakib Mullick <[email protected]>--- kernel/nsproxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/nsproxy.c +2
-2@@ -130,12 +130,12 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)if (!old_ns)return 0 ; -get_nsproxy (old_ns); -if (!(flags & (CLONE_NEWNS |CLONE_NEWUTS |CLONE_NEWIPC |CLONE_NEWPID |CLONE_NEWNET )))return 0 ; +get_nsproxy (old_ns); +if (!ns_capable (user_ns,CAP_SYS_ADMIN )) { err = -EPERM ; goto out;