[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230910-acl-fix-v2-1-38d6caa81419@kernel.org>
Date: Sun, 10 Sep 2023 15:30:48 -0400
From: Jeff Layton <jlayton@...nel.org>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Trond Myklebust <trond.myklebust@...merspace.com>,
Anna Schumaker <anna@...nel.org>,
Ondrej Valousek <ondrej.valousek.xm@...esas.com>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-nfs@...r.kernel.org, Jeff Layton <jlayton@...nel.org>
Subject: [PATCH v2] fs: add a new SB_NOUMASK flag
SB_POSIXACL must be set when a filesystem supports POSIX ACLs, but NFSv4
also sets this flag to prevent the VFS from applying the umask on
newly-created files. NFSv4 doesn't support POSIX ACLs however, which
causes confusion when other subsystems try to test for them.
Split the umask-stripping opt-out into a separate SB_NOUMASK flag, and
have NFSv4 set that instead of SB_POSIXACL. Fix the appropriate places
in the VFS to check for that flag (in addition to SB_POSIXACL) when
stripping the umask.
Signed-off-by: Jeff Layton <jlayton@...nel.org>
---
Yet another approach to fixing this issue. I think this way is probably
the best, since makes the purpose of these flags clearer, and stops NFS
from relying on SB_POSIXACL to avoid umask stripping.
---
Changes in v2:
- new approach: add a new SB_NOUMASK flag that NFSv4 can use instead of
SB_POSIXACL
- Link to v1: https://lore.kernel.org/r/20230908-acl-fix-v1-1-1e6b76c8dcc8@kernel.org
---
fs/init.c | 4 ++--
fs/namei.c | 2 +-
fs/nfs/super.c | 2 +-
include/linux/fs.h | 4 +++-
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/init.c b/fs/init.c
index 9684406a8416..157404bb7d19 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -153,7 +153,7 @@ int __init init_mknod(const char *filename, umode_t mode, unsigned int dev)
if (IS_ERR(dentry))
return PTR_ERR(dentry);
- if (!IS_POSIXACL(path.dentry->d_inode))
+ if (!IS_NOUMASK(path.dentry->d_inode))
mode &= ~current_umask();
error = security_path_mknod(&path, dentry, mode, dev);
if (!error)
@@ -229,7 +229,7 @@ int __init init_mkdir(const char *pathname, umode_t mode)
dentry = kern_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
- if (!IS_POSIXACL(path.dentry->d_inode))
+ if (!IS_NOUMASK(path.dentry->d_inode))
mode &= ~current_umask();
error = security_path_mkdir(&path, dentry, mode);
if (!error)
diff --git a/fs/namei.c b/fs/namei.c
index 567ee547492b..905fdfec5d26 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3117,7 +3117,7 @@ EXPORT_SYMBOL(unlock_rename);
*/
static inline umode_t mode_strip_umask(const struct inode *dir, umode_t mode)
{
- if (!IS_POSIXACL(dir))
+ if (!IS_NOUMASK(dir))
mode &= ~current_umask();
return mode;
}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 0d6473cb00cb..81cd11c4db3d 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1071,7 +1071,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx)
sb->s_export_op = &nfs_export_ops;
break;
case 4:
- sb->s_flags |= SB_POSIXACL;
+ sb->s_flags |= SB_NOUMASK;
sb->s_time_gran = 1;
sb->s_time_min = S64_MIN;
sb->s_time_max = S64_MAX;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4aeb3fa11927..51ad013ca716 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1119,13 +1119,14 @@ extern int send_sigurg(struct fown_struct *fown);
#define SB_NOATIME BIT(10) /* Do not update access times. */
#define SB_NODIRATIME BIT(11) /* Do not update directory access times */
#define SB_SILENT BIT(15)
-#define SB_POSIXACL BIT(16) /* VFS does not apply the umask */
+#define SB_POSIXACL BIT(16) /* POSIX ACLs are supported (implies NOUMASK) */
#define SB_INLINECRYPT BIT(17) /* Use blk-crypto for encrypted files */
#define SB_KERNMOUNT BIT(22) /* this is a kern_mount call */
#define SB_I_VERSION BIT(23) /* Update inode I_version field */
#define SB_LAZYTIME BIT(25) /* Update the on-disk [acm]times lazily */
/* These sb flags are internal to the kernel */
+#define SB_NOUMASK BIT(20) /* VFS does not apply the umask */
#define SB_DEAD BIT(21)
#define SB_DYING BIT(24)
#define SB_SUBMOUNT BIT(26)
@@ -2111,6 +2112,7 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags
#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
#define IS_POSIXACL(inode) __IS_FLG(inode, SB_POSIXACL)
+#define IS_NOUMASK(inode) __IS_FLG(inode, SB_POSIXACL|SB_NOUMASK)
#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
---
base-commit: a48fa7efaf1161c1c898931fe4c7f0070964233a
change-id: 20230908-acl-fix-6f8f86930f32
Best regards,
--
Jeff Layton <jlayton@...nel.org>
Powered by blists - more mailing lists