Skip to content

NAS-144980 / 27.0.0 / statx: report the POSIX ACLs a file has from the inode cache (by yocalebo) - #389

Merged
yocalebo merged 1 commit into
stable/27from
NAS-144980-27.0.0
Oct 30, 2026
Merged

yocalebo merged 1 commit into
stable/27from
NAS-144980-27.0.0

Conversation

@bugclerk

Copy link
Copy Markdown

A file server in userspace answers the acl and dacl attributes of NFSv4 and the ACCESS of a file from the mode alone when the file has no POSIX ACL. Finding that out takes a read of system.posix_acl_access for each file, and of system.posix_acl_default for each directory, where nfsd asks get_inode_acl and is answered from the ACLs the inode caches.

Add STATX_ACL, which asks vfs_getattr_nosec, on a file system that keeps POSIX ACLs, to look up the access ACL and, for a directory, the default ACL through get_inode_acl, and to set STATX_ATTR_ACL_ACCESS and STATX_ATTR_ACL_DEFAULT for those that exist. The first ask of a cold inode reads each once, and later asks are answered from the cache, which set_cached_acl and forget_cached_acl keep current as ACLs change. A file system keeps no access ACL that the mode already says all of, so one that exists is beyond the mode. Only presence is reported, which listxattr already shows. On an error, or on a kernel without this change, STATX_ACL is left out of stx_mask and the caller reads the ACL as before. A file system that reads its ACLs through ->get_acl alone, such as ecryptfs, answers without it too, since get_inode_acl with no dentry caches no ACL there, which getfacl would then show. Only a caller that asks pays for the lookup.

Original PR: #387

A file server in userspace answers the acl and dacl attributes of NFSv4
and the ACCESS of a file from the mode alone when the file has no POSIX
ACL. Finding that out takes a read of system.posix_acl_access for each
file, and of system.posix_acl_default for each directory, where nfsd
asks get_inode_acl and is answered from the ACLs the inode caches.

Add STATX_ACL, which asks vfs_getattr_nosec, on a file system that
keeps POSIX ACLs, to look up the access ACL and, for a directory, the
default ACL through get_inode_acl, and to set STATX_ATTR_ACL_ACCESS and
STATX_ATTR_ACL_DEFAULT for those that exist. The first ask of a cold
inode reads each once, and later asks are answered from the cache,
which set_cached_acl and forget_cached_acl keep current as ACLs change.
A file system keeps no access ACL that the mode already says all of, so
one that exists is beyond the mode. Only presence is reported, which
listxattr already shows. On an error, or on a kernel without this
change, STATX_ACL is left out of stx_mask and the caller reads the ACL
as before. A file system that reads its ACLs through ->get_acl alone,
such as ecryptfs, answers without it too, since get_inode_acl with no
dentry caches no ACL there, which getfacl would then show. Only a
caller that asks pays for the lookup.

(cherry picked from commit 8bc2de2)
@yocalebo
yocalebo merged commit 2feccad into stable/27 Oct 30, 2026
8 checks passed
@yocalebo
yocalebo deleted the NAS-144980-27.0.0 branch October 30, 2026 11:55
@bugclerk

Copy link
Copy Markdown
Author

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Oct 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants