[PATCH v4 06/12] ntfs: read ACLs using their stored size

From: Baolin Liu

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


From: Baolin Liu <liubaolin@xxxxxxxxxx>

The ACL setter accepts values larger than PATH_MAX, but ntfs_get_acl()
uses a fixed PATH_MAX buffer. Valid ACLs larger than 4096 bytes cannot be
read back after inode eviction. Inode-based ACL lookup also propagates
this error to permission checks and default ACL inheritance.

Query the EA length and allocate the required buffer with GFP_NOFS.
Keep the record lock across the size query and read so a concurrent ACL
replacement cannot change the required size in between.

Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations")
Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
New in v4.

Tested access/default ACLs of 4092, 4100 and 4836 bytes with 512-byte/4 KiB
clusters. Inheritance, permissions, remount and reboot checks passed for
regular files, O_TMPFILEs, directories and FIFOs.

fs/ntfs/ea.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 68397b2a4e43..834f38ea4a00 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -1019,11 +1019,7 @@ struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *den
size_t name_len;
struct posix_acl *acl;
int err;
- void *buf;
-
- buf = kmalloc(PATH_MAX, GFP_KERNEL);
- if (!buf)
- return ERR_PTR(-ENOMEM);
+ void *buf = NULL;

/* Possible values of 'type' was already checked above. */
if (type == ACL_TYPE_ACCESS) {
@@ -1035,7 +1031,14 @@ struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *den
}

mutex_lock(&ni->mrec_lock);
- err = ntfs_get_ea(inode, name, name_len, buf, PATH_MAX);
+ err = ntfs_get_ea(inode, name, name_len, NULL, 0);
+ if (err > 0) {
+ buf = kmalloc(err, GFP_NOFS);
+ if (!buf)
+ err = -ENOMEM;
+ else
+ err = ntfs_get_ea(inode, name, name_len, buf, err);
+ }
mutex_unlock(&ni->mrec_lock);

/* Translate extended attribute to acl. */