All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: don't forget to put old mntns in mntns_install
@ 2017-06-09  0:32 Andrei Vagin
  2017-06-16 20:41 ` Andrei Vagin
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Vagin @ 2017-06-09  0:32 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel, Andrei Vagin

Fixes: 4f757f3cbf54 ("make sure that mntns_install() doesn't end up with referral for root")
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
 fs/namespace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 8bd3e4d..5a44384 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3488,6 +3488,8 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
 		return err;
 	}
 
+	put_mnt_ns(old_mnt_ns);
+
 	/* Update the pwd and root */
 	set_fs_pwd(fs, &root);
 	set_fs_root(fs, &root);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs: don't forget to put old mntns in mntns_install
  2017-06-09  0:32 [PATCH] fs: don't forget to put old mntns in mntns_install Andrei Vagin
@ 2017-06-16 20:41 ` Andrei Vagin
  0 siblings, 0 replies; 2+ messages in thread
From: Andrei Vagin @ 2017-06-16 20:41 UTC (permalink / raw)
  To: Andrei Vagin; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

Hi Alexander,

Do you have any comments about this patch?

Here is a reproducer for this leak:

$ cat mount.sh 
set -e -x
mount --make-rprivate /
mount -t tmpfs zdtm /mnt
mount --make-shared /mnt
mount -t proc procX /proc
for i in `seq $1`; do
	mount --bind /mnt /mnt
done
mount --make-rprivate /mnt
unshare -m sleep 1000 &
pid=$!
unshare -m nsenter -m -t $pid nsenter -m -t $$ true


$ while :; do unshare -Umpfr sh mount.sh 16 || break; done

...

$ cat /proc/slabinfo | grep mnt
mnt_cache         3281745 3281776    512   16    2 : tunables    0    0 0 : slabdata 205111 205111      0


On Thu, Jun 08, 2017 at 05:32:29PM -0700, Andrei Vagin wrote:
> Fixes: 4f757f3cbf54 ("make sure that mntns_install() doesn't end up with referral for root")
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Andrei Vagin <avagin@openvz.org>
> ---
>  fs/namespace.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 8bd3e4d..5a44384 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -3488,6 +3488,8 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
>  		return err;
>  	}
>  
> +	put_mnt_ns(old_mnt_ns);
> +
>  	/* Update the pwd and root */
>  	set_fs_pwd(fs, &root);
>  	set_fs_root(fs, &root);
> -- 
> 2.9.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-16 20:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09  0:32 [PATCH] fs: don't forget to put old mntns in mntns_install Andrei Vagin
2017-06-16 20:41 ` Andrei Vagin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.