public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Rakib Mullick <rakib.mullick@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Serge Hallyn <serge.hallyn@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] nsproxy: Fix ->nsproxy counting problem in copy_namespace.
Date: Thu, 07 Mar 2013 02:14:56 -0800	[thread overview]
Message-ID: <87r4jrv7mn.fsf@xmission.com> (raw)
In-Reply-To: <1362649361.14735.5.camel@beeld> (Rakib Mullick's message of "Thu, 07 Mar 2013 15:42:41 +0600")


Thanks applied.

This is an unpleasant accidental memory leak.

Eric


Rakib Mullick <rakib.mullick@gmail.com> writes:

> From cd41495e25cf2641ffe9e01a40d3d221a46b08be Mon Sep 17 00:00:00 2001
> From: Rakib Mullick <rakib.mullick@gmail.com>
> 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.
>
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
> ---
>  kernel/nsproxy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
> index afc0456..de36209 100644
> --- a/kernel/nsproxy.c
> +++ b/kernel/nsproxy.c
> @@ -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;

      reply	other threads:[~2013-03-07 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07  9:42 [PATCH] nsproxy: Fix ->nsproxy counting problem in copy_namespace Rakib Mullick
2013-03-07 10:14 ` Eric W. Biederman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4jrv7mn.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rakib.mullick@gmail.com \
    --cc=serge.hallyn@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox