From: Jeff Layton <jlayton@kernel.org>
To: Christian Brauner <brauner@kernel.org>,
Andreas Dilger <adilger@dilger.ca>
Cc: NeilBrown <neilb@suse.de>, Al Viro <viro@zeniv.linux.org.uk>,
Dave Wysochanski <dwysocha@redhat.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-nfs <linux-nfs@vger.kernel.org>,
David Howells <dhowells@redhat.com>,
Christoph Hellwig <hch@lst.de>, Karel Zak <kzak@redhat.com>
Subject: Re: [PATCH/RFC] VFS: LOOKUP_MOUNTPOINT should used cached info whenever possible.
Date: Thu, 20 Apr 2023 09:05:47 -0400 [thread overview]
Message-ID: <94b793956c464ccccbaf064f6d18f1821801c140.camel@kernel.org> (raw)
In-Reply-To: <20230418-windrad-bezahlbar-0ef93bef8f3f@brauner>
On Tue, 2023-04-18 at 10:04 +0200, Christian Brauner wrote:
> On Mon, Apr 17, 2023 at 09:25:20PM -0600, Andreas Dilger wrote:
> >
> > > On Apr 17, 2023, at 9:21 AM, Jeff Layton <jlayton@kernel.org> wrote:
> > >
> > > On Mon, 2023-04-17 at 16:24 +0200, Christian Brauner wrote:
> > > > And I'm curious why is it obvious that we don't want to revalidate _any_
> > > > path component and not just the last one? Why is that generally safe?
> > > > Why can't this be used to access files and directories the caller
> > > > wouldn't otherwise be able to access? I would like to have this spelled
> > > > out for slow people like me, please.
> > > >
> > > > From my point of view, this would only be somewhat safe _generally_ if
> > > > you'd allow circumvention for revalidation and permission checking if
> > > > MNT_FORCE is specified and the caller has capable(CAP_DAC_READ_SEARCH).
> > > > You'd still mess with overlayfs permission model in this case though.
> > > >
> > > > Plus, there are better options of solving this problem. Again, I'd
> > > > rather build a separate api for unmounting then playing such potentially
> > > > subtle security sensitive games with permission checking during path
> > > > lookup.
> > >
> > > umount(2) is really a special case because the whole intent is to detach
> > > a mount from the local hierarchy and stop using it. The unfortunate bit
> > > is that it is a path-based syscall.
> > >
> > > So usually we have to:
> > >
> > > - determine the path: Maybe stat() it and to validate that it's the
> > > mountpoint we want to drop
> >
> > The stat() itself may hang because a remote server, or USB stick is
> > inaccessible or having media errors.
> >
> > I've just been having a conversation with Karel Zak to change
> > umount(1) to use statx() so that it interacts minimally with the fs.
>
> So we're talking about this commit:
> https://github.com/util-linux/util-linux/commit/42e141d20505a0deb969c2e583a463c26aadc62f
> and the patch we discussed here:
> https://github.com/util-linux/util-linux/issues/2049
>
> >
> > In particular, nfs_getattr() skips revalidate if only minimal attrs
> > are fetched (STATX_TYPE | STATX_INO), and also skips revalidate if
> > locally-cached attrs are still valid (STATX_MODE), so this will
> > avoid yet one more place that unmount can hang.
> >
> > In theory, vfs_getattr() could get all of these attributes directly
> > from the vfs_inode in the unmount case.
>
> We don't really need that. As pointed out in that discussion and as
> Karel did we just want to pass AT_STATX_DONT_SYNC.
>
> An api that would allow unmounting by mount id can safely check and
> retrieve AT_STATX_DONT_SYNC with STATX_ATTR_MOUNT_ROOT and STATX_MNT_ID
> without ever syncing with the server.
Unfortunately, I don't think that flag trickles down to the ->permission
checks for the pathwalk down to the point you're stat'ing. That turns
out to be a big part of the problem when trying to umount things that
are stuck down in inaccessible trees.
I'm not opposed at all to new APIs that allow for more reliable
unmounting. I think that's a good idea, and something worth hashing out.
But...we're stuck with umount() in perpetuity. Even if you were to merge
a new API for unmounting today, it'll be a decade or more until the
ecosystem catches up. I think we have a responsibility to make the
umount syscall work as well as we can. In this case, that means giving
it as light a footprint as possible on the pathwalk down.
If we need to gate this behavior behind existing or new flags to
umount2(), then so be it, but lets not dismiss this idea in favor of
some new unmounting interface that may never materialize. Improving
umount has the potential to help a lot of our users.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2023-04-20 13:05 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 22:00 allowing for a completely cached umount(2) pathwalk Jeff Layton
2023-04-13 22:25 ` Andreas Dilger
2023-04-13 22:41 ` NeilBrown
2023-04-14 2:43 ` Al Viro
2023-04-14 3:28 ` Trond Myklebust
2023-04-14 3:51 ` Al Viro
2023-04-14 4:06 ` Trond Myklebust
2023-04-14 4:21 ` Al Viro
2023-04-14 9:41 ` Christian Brauner
2023-04-14 10:09 ` Jeff Layton
2023-04-14 11:16 ` Christian Brauner
2023-04-14 12:33 ` Jeff Layton
2023-04-14 12:51 ` Christian Brauner
2023-04-15 9:51 ` Amir Goldstein
2023-04-14 10:06 ` Jeff Layton
2023-04-14 13:41 ` Christian Brauner
2023-04-14 14:21 ` Trond Myklebust
2023-04-14 15:13 ` Christian Brauner
2023-04-14 15:30 ` Trond Myklebust
2023-04-14 15:57 ` Trond Myklebust
2023-04-14 16:22 ` Al Viro
2023-04-14 16:41 ` Trond Myklebust
2023-04-14 19:01 ` Benjamin Coddington
2023-04-17 8:22 ` Christian Brauner
2023-04-14 16:32 ` Christian Brauner
2023-04-14 2:32 ` Al Viro
2023-04-14 10:01 ` Jeff Layton
2023-04-14 12:18 ` Christian Brauner
2023-04-14 14:57 ` Al Viro
2023-04-14 13:16 ` David Wysochanski
2023-04-16 23:13 ` [PATCH/RFC] VFS: LOOKUP_MOUNTPOINT should used cached info whenever possible NeilBrown
2023-04-17 11:55 ` Christian Brauner
2023-04-17 12:25 ` Jeff Layton
2023-04-17 14:24 ` Christian Brauner
2023-04-17 15:21 ` Jeff Layton
2023-04-17 21:34 ` NeilBrown
2023-04-18 8:10 ` Christian Brauner
2023-04-18 3:25 ` Andreas Dilger
2023-04-18 8:04 ` Christian Brauner
2023-04-20 13:05 ` Jeff Layton [this message]
2023-04-20 15:41 ` Christian Brauner
2023-04-17 21:26 ` NeilBrown
2023-04-20 21:35 ` Al Viro
2023-04-20 22:01 ` NeilBrown
2023-04-20 22:27 ` Al Viro
2023-04-17 12:09 ` Jeff Layton
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=94b793956c464ccccbaf064f6d18f1821801c140.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=adilger@dilger.ca \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=dwysocha@redhat.com \
--cc=hch@lst.de \
--cc=kzak@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=viro@zeniv.linux.org.uk \
/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