LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serge@hallyn.com>
To: Alexey Dobriyan <adobriyan@openvz.org>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org, devel@openvz.org
Subject: Re: [PATCH] Introduce and use get_task_mnt_ns()
Date: Wed, 17 Jan 2007 13:21:48 -0600 [thread overview]
Message-ID: <20070117192148.GA13894@vino.hallyn.com> (raw)
In-Reply-To: <20070117154319.GD6021@localhost.sw.ru>
Quoting Alexey Dobriyan (adobriyan@openvz.org):
> Apply after "[PATCH] Fix NULL ->nsproxy dereference in /proc/*/mounts".
>
> Similar to get_task_mm(): get a reference to task's mnt namespace if any.
> Suggested by Pavel Emelianov.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Yeah, that's nicer, thanks.
Acked-by: Serge Hallyn <serue@us.ibm.com>
> ---
>
> fs/proc/base.c | 15 ++-------------
> include/linux/nsproxy.h | 1 +
> kernel/nsproxy.c | 14 ++++++++++++++
> 3 files changed, 17 insertions(+), 13 deletions(-)
>
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -370,13 +370,7 @@ static int mounts_open(struct inode *ino
> int ret = -EINVAL;
>
> if (task) {
> - task_lock(task);
> - if (task->nsproxy) {
> - ns = task->nsproxy->mnt_ns;
> - if (ns)
> - get_mnt_ns(ns);
> - }
> - task_unlock(task);
> + ns = get_task_mnt_ns(task);
> put_task_struct(task);
> }
>
> @@ -443,12 +437,7 @@ static int mountstats_open(struct inode
> struct task_struct *task = get_proc_task(inode);
>
> if (task) {
> - task_lock(task);
> - if (task->nsproxy)
> - mnt_ns = task->nsproxy->mnt_ns;
> - if (mnt_ns)
> - get_mnt_ns(mnt_ns);
> - task_unlock(task);
> + mnt_ns = get_task_mnt_ns(task);
> put_task_struct(task);
> }
>
> --- a/include/linux/nsproxy.h
> +++ b/include/linux/nsproxy.h
> @@ -35,6 +35,7 @@ struct nsproxy *dup_namespaces(struct ns
> int copy_namespaces(int flags, struct task_struct *tsk);
> void get_task_namespaces(struct task_struct *tsk);
> void free_nsproxy(struct nsproxy *ns);
> +struct mnt_namespace * get_task_mnt_ns(struct task_struct *tsk);
>
> static inline void put_nsproxy(struct nsproxy *ns)
> {
> --- a/kernel/nsproxy.c
> +++ b/kernel/nsproxy.c
> @@ -147,3 +147,17 @@ void free_nsproxy(struct nsproxy *ns)
> put_pid_ns(ns->pid_ns);
> kfree(ns);
> }
> +
> +struct mnt_namespace * get_task_mnt_ns(struct task_struct *tsk)
> +{
> + struct mnt_namespace *mnt_ns = NULL;
> +
> + task_lock(tsk);
> + if (tsk->nsproxy)
> + mnt_ns = tsk->nsproxy->mnt_ns;
> + if (mnt_ns)
> + get_mnt_ns(mnt_ns);
> + task_unlock(tsk);
> +
> + return mnt_ns;
> +}
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2007-01-17 19:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-17 15:43 Alexey Dobriyan
2007-01-17 19:21 ` Serge E. Hallyn [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=20070117192148.GA13894@vino.hallyn.com \
--to=serge@hallyn.com \
--cc=adobriyan@openvz.org \
--cc=akpm@osdl.org \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH] Introduce and use get_task_mnt_ns()' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).