Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753873AbYAHS0x (ORCPT ); Tue, 8 Jan 2008 13:26:53 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750707AbYAHS0n (ORCPT ); Tue, 8 Jan 2008 13:26:43 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:46242 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbYAHS0m (ORCPT ); Tue, 8 Jan 2008 13:26:42 -0500 Subject: Re: [patch 5/9] unprivileged mounts: allow unprivileged bind mounts From: Dave Hansen To: Miklos Szeredi Cc: akpm@linux-foundation.org, hch@infradead.org, serue@us.ibm.com, viro@ftp.linux.org.uk, ebiederm@xmission.com, kzak@redhat.com, linux-fsdevel@vger.kernel.org, containers@lists.osdl.org, util-linux-ng@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20080108113626.895583537@szeredi.hu> References: <20080108113502.184459371@szeredi.hu> <20080108113626.895583537@szeredi.hu> Content-Type: text/plain Date: Tue, 08 Jan 2008 10:26:26 -0800 Message-Id: <1199816786.9834.70.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1548 Lines: 42 On Tue, 2008-01-08 at 12:35 +0100, Miklos Szeredi wrote: > @@ -510,10 +533,16 @@ static struct vfsmount *clone_mnt(struct > int flag) > { > struct super_block *sb = old->mnt_sb; > - struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname); > + struct vfsmount *mnt; > > + if (flag & CL_SETUSER) { > + int err = reserve_user_mount(); > + if (err) > + return ERR_PTR(err); > + } > + mnt = alloc_vfsmnt(old->mnt_devname); > if (!mnt) > - return ERR_PTR(-ENOMEM); > + goto alloc_failed; > > mnt->mnt_flags = old->mnt_flags; > atomic_inc(&sb->s_active); I think there's a little race here. We could have several users racing to get to this point when nr_user_mounts==max_user_mounts-1. One user wins the race and gets their mount reserved. The others get the error out of reserve_user_mount(), and return. But, the winner goes on to error out on some condition further down in clone_mnt() and never actually instantiates the mount. Do you think this is a problem? I think just about the one solution is to block new mounters on a sleepable lock until the race winner actually finishes their mount operation. -- Dave -- 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/