From: "NeilBrown" <neilb@suse.de>
To: "Kent Overstreet" <kent.overstreet@linux.dev>
Cc: "Christian Brauner" <brauner@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Jan Kara" <jack@suse.cz>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Trond Myklebust" <trondmy@kernel.org>,
"Anna Schumaker" <anna@kernel.org>,
"Namjae Jeon" <linkinjeon@kernel.org>,
"Steve French" <sfrench@samba.org>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
"Tom Talpey" <tom@talpey.com>, "Paul Moore" <paul@paul-moore.com>,
"Eric Paris" <eparis@redhat.com>,
linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-cifs@vger.kernel.org, audit@vger.kernel.org
Subject: Re: [PATCH 1/2] VFS: change kern_path_locked() and user_path_locked_at() to never return negative dentry
Date: Fri, 07 Feb 2025 15:53:52 +1100 [thread overview]
Message-ID: <173890403265.22054.8267826472424760232@noble.neil.brown.name> (raw)
In-Reply-To: <6p2m4jqtl62cabb2xolxt76ycule5prukjzx4nxklvhk23g6qh@luj2tzicloph>
On Fri, 07 Feb 2025, Kent Overstreet wrote:
> On Fri, Feb 07, 2025 at 02:36:47PM +1100, NeilBrown wrote:
> > No callers of kern_path_locked() or user_path_locked_at() want a
> > negative dentry. So change them to return -ENOENT instead. This
> > simplifies callers.
> >
> > This results in a subtle change to bcachefs in that an ioctl will now
> > return -ENOENT in preference to -EXDEV. I believe this restores the
> > behaviour to what it was prior to
>
> I'm not following how the code change matches the commit message?
Maybe it doesn't. Let me checked.
Two of the possible error returns from bch2_ioctl_subvolume_destroy(),
which implements the BCH_IOCTL_SUBVOLUME_DESTROY ioctl, are -ENOENT and
-EXDEV.
-ENOENT is returned if the path named in arg.dst_ptr cannot be found.
-EXDEV is returned if the filesystem on which that path exists is not
the one that the ioctl is called on.
If the target filesystem is "/foo" and the path given is "/bar/baz" and
/bar exists but /bar/baz does not, then user_path_locked_at or
user_path_at will return a negative dentry corresponding to the
(non-existent) name "baz" in /bar.
In this case the dentry exists so the filesystem on which it was found
can be tested, but the dentry is negative. So both -ENOENT and -EXDEV
are credible return values.
- before bbe6a7c899e7 the -EXDEV is tested immediately after the call
to user_path_att() so there is no chance that ENOENT will be returned.
I cannot actually find where ENOENT could be returned ... but that
doesn't really matter now.
- after that patch .... again the -EXDEV test comes first. That isn't
what I remember. I must have misread it.
- after my patch user_path_locked_at() will return -ENOENT if the whole
name cannot be found. So now you get -ENOENT instead of -EXDEV.
So with my patch, ENOENT always wins, and it was never like that before.
Thanks for challenging me!
Do you think there could be a problem with changing the error returned
in this circumstance? i.e. if you try to destroy a subvolume with a
non-existant name on a different filesystem could getting -ENOENT
instead of -EXDEV be noticed?
Thanks,
NeilBrown
next prev parent reply other threads:[~2025-02-07 4:54 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 3:36 [PATCH 0/2] VFS: minor improvements to a couple of interfaces NeilBrown
2025-02-07 3:36 ` [PATCH 1/2] VFS: change kern_path_locked() and user_path_locked_at() to never return negative dentry NeilBrown
2025-02-07 3:46 ` Kent Overstreet
2025-02-07 4:53 ` NeilBrown [this message]
2025-02-07 6:13 ` Kent Overstreet
2025-02-07 6:34 ` NeilBrown
2025-02-07 6:51 ` Kent Overstreet
2025-02-07 7:30 ` NeilBrown
2025-02-07 13:35 ` Kent Overstreet
2025-02-10 1:20 ` NeilBrown
2025-02-10 16:33 ` Kent Overstreet
2025-02-12 3:24 ` NeilBrown
2025-02-07 6:51 ` [PATCH 1/2 v2] " NeilBrown
2025-02-07 6:53 ` [PATCH 1/2] " NeilBrown
2025-02-07 19:09 ` Paul Moore
2025-02-07 3:36 ` [PATCH 2/2] VFS: add common error checks to lookup_one_qstr_excl() NeilBrown
2025-02-12 2:50 ` kernel test robot
2025-02-12 3:16 ` Al Viro
2025-02-12 3:25 ` Al Viro
2025-02-12 3:45 ` NeilBrown
2025-02-12 4:06 ` Al Viro
2025-02-12 4:40 ` NeilBrown
2025-02-10 8:25 ` [PATCH 0/2] VFS: minor improvements to a couple of interfaces Christian Brauner
2025-02-10 8:42 ` Al Viro
2025-02-10 9:41 ` Christian Brauner
-- strict thread matches above, loose matches on Subject: below --
2025-02-17 0:27 [PATCH 0/2 v2] " NeilBrown
2025-02-17 0:27 ` [PATCH 1/2] VFS: change kern_path_locked() and user_path_locked_at() to never return negative dentry NeilBrown
2025-02-17 8:26 ` Christian Brauner
2025-02-17 13:41 ` Jeff Layton
2025-04-14 11:01 ` Christian Brauner
2025-04-14 15:54 ` 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=173890403265.22054.8267826472424760232@noble.neil.brown.name \
--to=neilb@suse.de \
--cc=anna@kernel.org \
--cc=audit@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=dakr@kernel.org \
--cc=eparis@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=kent.overstreet@linux.dev \
--cc=linkinjeon@kernel.org \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=rafael@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=sfrench@samba.org \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).