From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Eric Sandeen <sandeen@redhat.com>,
linux-fsdevel@vger.kernel.org, autofs@vger.kernel.org,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-efi@vger.kernel.org, Namjae Jeon <linkinjeon@kernel.org>,
linux-ext4@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
linux-mm@kvack.org, ntfs3@lists.linux.dev,
linux-cifs@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Hans Caniullan <hcaniull@redhat.com>
Subject: Re: [PATCH 01/14] fs_parse: add uid & gid option option parsing helpers
Date: Mon, 1 Jul 2024 11:34:37 +0200 [thread overview]
Message-ID: <20240701093437.d2654yek4nnq2ep6@quack3> (raw)
In-Reply-To: <20240628-fernfahrt-missverstanden-01543e7492b4@brauner>
On Fri 28-06-24 14:23:35, Christian Brauner wrote:
> On Fri, Jun 28, 2024 at 11:45:17AM GMT, Jan Kara wrote:
> > On Thu 27-06-24 19:26:24, Eric Sandeen wrote:
> > > Multiple filesystems take uid and gid as options, and the code to
> > > create the ID from an integer and validate it is standard boilerplate
> > > that can be moved into common helper functions, so do that for
> > > consistency and less cut&paste.
> > >
> > > This also helps avoid the buggy pattern noted by Seth Jenkins at
> > > https://lore.kernel.org/lkml/CALxfFW4BXhEwxR0Q5LSkg-8Vb4r2MONKCcUCVioehXQKr35eHg@mail.gmail.com/
> > > because uid/gid parsing will fail before any assignment in most
> > > filesystems.
> > >
> > > Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
> >
> > I like the idea since this seems like a nobrainer but is actually
> > surprisingly subtle...
> >
> > > diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> > > index a4d6ca0b8971..24727ec34e5a 100644
> > > --- a/fs/fs_parser.c
> > > +++ b/fs/fs_parser.c
> > > @@ -308,6 +308,40 @@ int fs_param_is_fd(struct p_log *log, const struct fs_parameter_spec *p,
> > > }
> > > EXPORT_SYMBOL(fs_param_is_fd);
> > >
> > > +int fs_param_is_uid(struct p_log *log, const struct fs_parameter_spec *p,
> > > + struct fs_parameter *param, struct fs_parse_result *result)
> > > +{
> > > + kuid_t uid;
> > > +
> > > + if (fs_param_is_u32(log, p, param, result) != 0)
> > > + return fs_param_bad_value(log, param);
> > > +
> > > + uid = make_kuid(current_user_ns(), result->uint_32);
> >
> > But here is the problem: Filesystems mountable in user namespaces need to use
> > fc->user_ns for resolving uids / gids (e.g. like fuse_parse_param()).
> > Having helpers that work for some filesystems and are subtly broken for
> > others is worse than no helpers... Or am I missing something?
> >
> > And the problem with fc->user_ns is that currently __fs_parse() does not
> > get fs_context as an argument... So that will need some larger work.
>
> Not really. If someone does an fsopen() in a namespace but the process
> that actually sets mount options is in another namespace then it's
> completely intransparent what uid/gid this will resolve to if it's
> resovled according to fsopen().
>
> It's also a bit strange if someone ends up handing off a tmpfs fscontext
> that was created in the initial namespace to some random namespace and
> they now can set uid/gid options that aren't mapped according to their
> namespace but instead are 1:1 resolved according to the intial
> namespace. So this would hinder delegation.
>
> The expectation is that uid/gid options are resolved in the caller's
> namespace and that shouldn't be any different for fscontexts for
> namespace mountable filesystems. The crucial point is to ensure that the
> resulting kuid/kgid can be resolved in the namespace the filesystem is
> mounted in at the end. That's what was lacking in e.g., tmpfs in commit
> 0200679fc795 ("tmpfs: verify {g,u}id mount options correctly")
>
> The fuse conversion is the only inconsistency in that regard.
OK, thanks for explanation!
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-07-01 9:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 0:24 [PATCH 0/14] New uid & gid mount " Eric Sandeen
2024-06-28 0:26 ` [PATCH 01/14] fs_parse: add uid & gid option " Eric Sandeen
2024-06-28 9:45 ` Jan Kara
2024-06-28 12:23 ` Christian Brauner
2024-07-01 9:34 ` Jan Kara [this message]
2024-06-28 13:44 ` Eric Sandeen
2024-06-28 0:35 ` [PATCH 08/14] hugetlbfs: Convert to new uid/gid " Eric Sandeen
2024-06-28 0:38 ` [PATCH 11/14] tmpfs: " Eric Sandeen
2024-06-28 11:51 ` [PATCH 0/14] New uid & gid mount " Christian Brauner
2024-07-02 4:25 ` (subset) " Christian Brauner
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=20240701093437.d2654yek4nnq2ep6@quack3 \
--to=jack@suse.cz \
--cc=autofs@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=hcaniull@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=ntfs3@lists.linux.dev \
--cc=rafael@kernel.org \
--cc=sandeen@redhat.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox