public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Christian Brauner <brauner@kernel.org>
Cc: Stefan Berger <stefanb@linux.ibm.com>, linux-fsdevel@vger.kernel.org
Subject: [WTF?] AT_GETATTR_NOSEC checks
Date: Fri, 1 Nov 2024 01:17:24 +0000	[thread overview]
Message-ID: <20241101011724.GN1350452@ZenIV> (raw)

	AFAICS, since the moment it had been introduced it got passed
to *ALL* ->getattr() calls.  Unconditionally.  So why are we checking
it in ecryptfs and overlayfs instances?

Look: all direct calls of instances are from other instances, with
query_flags passed unchanged.  There is only one call via method -
that in vfs_getattr_nosec(), but that caller explicitly adds
AT_GETATTR_NOSEC to query_flags.

So what the hell are the checks in ecryptfs and overlayfs for?
What am I missing here?  What would break if we did the following:

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 5ed1e4cf6c0b..255e60bd7dca 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1008,14 +1008,6 @@ static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
 	return rc;
 }
 
-static int ecryptfs_do_getattr(const struct path *path, struct kstat *stat,
-			       u32 request_mask, unsigned int flags)
-{
-	if (flags & AT_GETATTR_NOSEC)
-		return vfs_getattr_nosec(path, stat, request_mask, flags);
-	return vfs_getattr(path, stat, request_mask, flags);
-}
-
 static int ecryptfs_getattr(struct mnt_idmap *idmap,
 			    const struct path *path, struct kstat *stat,
 			    u32 request_mask, unsigned int flags)
@@ -1024,7 +1016,7 @@ static int ecryptfs_getattr(struct mnt_idmap *idmap,
 	struct kstat lower_stat;
 	int rc;
 
-	rc = ecryptfs_do_getattr(ecryptfs_dentry_to_lower_path(dentry),
+	rc = vfs_getattr_nosec(ecryptfs_dentry_to_lower_path(dentry),
 				 &lower_stat, request_mask, flags);
 	if (!rc) {
 		fsstack_copy_attr_all(d_inode(dentry),
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 0bfe35da4b7b..dde85ec96444 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -415,9 +415,8 @@ static inline bool ovl_open_flags_need_copy_up(int flags)
 static inline int ovl_do_getattr(const struct path *path, struct kstat *stat,
 				 u32 request_mask, unsigned int flags)
 {
-	if (flags & AT_GETATTR_NOSEC)
-		return vfs_getattr_nosec(path, stat, request_mask, flags);
-	return vfs_getattr(path, stat, request_mask, flags);
+	BUG_ON(!(flags & AT_GETATTR_NOSEC));
+	return vfs_getattr_nosec(path, stat, request_mask, flags);
 }
 
 /* util.c */

             reply	other threads:[~2024-11-01  1:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-01  1:17 Al Viro [this message]
2024-11-06 10:27 ` [WTF?] AT_GETATTR_NOSEC checks 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=20241101011724.GN1350452@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=stefanb@linux.ibm.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