Return-Path: Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:41248 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750873AbdFPUl0 (ORCPT ); Fri, 16 Jun 2017 16:41:26 -0400 Date: Fri, 16 Jun 2017 13:41:05 -0700 From: Andrei Vagin To: Andrei Vagin Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: don't forget to put old mntns in mntns_install Message-ID: <20170616204103.GA2721@outlook.office365.com> References: <20170609003229.22427-1-avagin@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20170609003229.22427-1-avagin@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 > Signed-off-by: Andrei Vagin > --- > 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 >