[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201102132932.pseijsddvxo5hgpf@wittgenstein>
Date: Mon, 2 Nov 2020 14:29:32 +0100
From: Christian Brauner <christian.brauner@...ntu.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org,
John Johansen <john.johansen@...onical.com>,
James Morris <jmorris@...ei.org>,
Mimi Zohar <zohar@...ux.ibm.com>,
Dmitry Kasatkin <dmitry.kasatkin@...il.com>,
Stephen Smalley <stephen.smalley.work@...il.com>,
Casey Schaufler <casey@...aufler-ca.com>,
Arnd Bergmann <arnd@...db.de>,
Andreas Dilger <adilger.kernel@...ger.ca>,
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
Geoffrey Thomas <geofft@...reload.com>,
Mrunal Patel <mpatel@...hat.com>,
Josh Triplett <josh@...htriplett.org>,
Andy Lutomirski <luto@...nel.org>,
Amir Goldstein <amir73il@...il.com>,
Miklos Szeredi <miklos@...redi.hu>,
Theodore Tso <tytso@....edu>, Alban Crequy <alban@...volk.io>,
Tycho Andersen <tycho@...ho.ws>,
David Howells <dhowells@...hat.com>,
James Bottomley <James.Bottomley@...senpartnership.com>,
Jann Horn <jannh@...gle.com>,
Seth Forshee <seth.forshee@...onical.com>,
St??phane Graber <stgraber@...ntu.com>,
Aleksa Sarai <cyphar@...har.com>,
Lennart Poettering <lennart@...ttering.net>,
"Eric W. Biederman" <ebiederm@...ssion.com>, smbarber@...omium.org,
Phil Estes <estesp@...il.com>, Serge Hallyn <serge@...lyn.com>,
Kees Cook <keescook@...omium.org>,
Todd Kjos <tkjos@...gle.com>, Jonathan Corbet <corbet@....net>,
containers@...ts.linux-foundation.org,
linux-security-module@...r.kernel.org, linux-api@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-unionfs@...r.kernel.org,
linux-audit@...hat.com, linux-integrity@...r.kernel.org,
selinux@...r.kernel.org
Subject: Re: [PATCH 05/34] fs: introduce MOUNT_ATTR_IDMAP
On Sun, Nov 01, 2020 at 02:45:44PM +0000, Christoph Hellwig wrote:
> On Thu, Oct 29, 2020 at 01:32:23AM +0100, Christian Brauner wrote:
> > Introduce a new mount bind mount property to allow idmapping mounts. The
> > MOUNT_ATTR_IDMAP flag can be set via the new mount_setattr() syscall
> > together with a file descriptor referring to a user namespace.
>
> Shouldn't this go to the end of the series once all the infrastructure
> is in place?
Yeah, good idea. (I mostly did it to keep compile-times short when
rebasing.)
>
> > +config IDMAP_MOUNTS
> > + bool "Support id mappings per mount"
> > + default n
>
> n is the default default.
Ah, thanks.
>
> But why do we need a config option here anyway?
My main concern was people complaining about code they want to compile
out. I've been burnt by that before but I'm happy to remove the config
option and make this unconditional.
>
> > +#ifdef CONFIG_IDMAP_MOUNTS
> > + if (kattr->attr_set & MNT_IDMAPPED) {
> > + struct user_namespace *user_ns;
> > + struct vfsmount *vmnt;
>
> All the code here looks like it should go into a helper.
Will do.
>
> > + struct user_namespace *user_ns = READ_ONCE(m->mnt.mnt_user_ns);
> > + WRITE_ONCE(m->mnt.mnt_user_ns, get_user_ns(kattr->userns));
>
> More unreadable long lines.
Will wrap. I have somewhat adapted to the more lax 100 limit but I'm
happy to stick to 80.
>
> > + if (attr->attr_set & MOUNT_ATTR_IDMAP) {
> > + struct ns_common *ns;
> > + struct user_namespace *user_ns;
> > + struct file *file;
> > +
> > + file = fget(attr->userns);
>
> The code here looks like another candidate for a self contained helper.
Noted.
>
> > +
> > +static inline struct user_namespace *mnt_user_ns(const struct vfsmount *mnt)
> > +{
> > +#ifdef CONFIG_IDMAP_MOUNTS
> > + return READ_ONCE(mnt->mnt_user_ns);
> > +#else
> > + return &init_user_ns;
> > +#endif
>
> How is the READ_ONCE on a pointer going to work?
Honestly, this is me following a pattern I've seen in other places and
it's mostly about visually indicating concurrency but I'll drop it.
Christian
Powered by blists - more mailing lists