[PATCH v4 07/12] ntfs: load uncached ACLs through get_inode_acl

From: Baolin Liu

Date: Sun Nov 15 2026 - 08:26:45 EST


From: Baolin Liu <liubaolin@xxxxxxxxxx>

Permission checks and default ACL inheritance use get_inode_acl(), which
cannot call NTFS's dentry-based get_acl callback. After inode eviction,
these paths treat stored ACLs as absent unless an explicit xattr read
has populated the cache.

Use get_inode_acl for regular files, directories and special files,
leaving ACL caching to the VFS. Return -ECHILD during RCU lookup so the
VFS retries where the EA read can sleep.

Fixes: 9c87959601e8 ("ntfs: update file operations")
Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
New in v4.

Tested cold-cache inheritance and permissions, O_TMPFILE publication,
chmod, ACL replacement/removal, idmapped mounts and concurrent default
ACL replacement/creation. Remount and reboot checks passed.

fs/ntfs/ea.c | 10 ++++------
fs/ntfs/ea.h | 3 +--
fs/ntfs/file.c | 4 ++--
fs/ntfs/namei.c | 2 +-
4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 834f38ea4a00..b745391b3f25 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -1010,10 +1010,8 @@ const struct xattr_handler * const ntfs_xattr_handlers[] = {
// clang-format on

#ifdef CONFIG_NTFS_FS_POSIX_ACL
-struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
- int type)
+struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu)
{
- struct inode *inode = d_inode(dentry);
struct ntfs_inode *ni = NTFS_I(inode);
const char *name;
size_t name_len;
@@ -1021,6 +1019,9 @@ struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *den
int err;
void *buf = NULL;

+ if (rcu)
+ return ERR_PTR(-ECHILD);
+
/* Possible values of 'type' was already checked above. */
if (type == ACL_TYPE_ACCESS) {
name = XATTR_NAME_POSIX_ACL_ACCESS;
@@ -1049,9 +1050,6 @@ struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *den
else
acl = ERR_PTR(err);

- if (!IS_ERR(acl))
- set_cached_acl(inode, type, acl);
-
kfree(buf);

return acl;
diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
index f200d49063e0..e9ea024f6a8e 100644
--- a/fs/ntfs/ea.h
+++ b/fs/ntfs/ea.h
@@ -28,8 +28,7 @@ int ntfs_ea_set_linuxflags(struct inode *inode, u32 linuxflags);
ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);

#ifdef CONFIG_NTFS_FS_POSIX_ACL
-struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
- int type);
+struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu);
int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 5ab0e3437d67..a52483d16c6e 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -1580,7 +1580,7 @@ const struct inode_operations ntfs_file_inode_ops = {
.fileattr_get = ntfs_fileattr_get,
.fileattr_set = ntfs_fileattr_set,
.listxattr = ntfs_listxattr,
- .get_acl = ntfs_get_acl,
+ .get_inode_acl = ntfs_get_acl,
.set_acl = ntfs_set_acl,
.fiemap = ntfs_fiemap,
};
@@ -1600,7 +1600,7 @@ const struct inode_operations ntfs_special_inode_operations = {
.listxattr = ntfs_listxattr,
.fileattr_get = ntfs_fileattr_get,
.fileattr_set = ntfs_fileattr_set,
- .get_acl = ntfs_get_acl,
+ .get_inode_acl = ntfs_get_acl,
.set_acl = ntfs_set_acl,
};

diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 05e2747bae54..d3c63b1c166f 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1703,7 +1703,7 @@ const struct inode_operations ntfs_dir_inode_ops = {
.mkdir = ntfs_mkdir,
.rmdir = ntfs_rmdir,
.rename = ntfs_rename,
- .get_acl = ntfs_get_acl,
+ .get_inode_acl = ntfs_get_acl,
.set_acl = ntfs_set_acl,
.listxattr = ntfs_listxattr,
.setattr = ntfs_setattr,