Skip to content

tmpfs: implement POSIX ACLs - #13885

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl955529312
Open

tmpfs: implement POSIX ACLs#13885
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl955529312

Conversation

@copybara-service

Copy link
Copy Markdown

tmpfs: implement POSIX ACLs

Implements POSIX ACLs for gVisor's tmpfs. As a summary:

  • Adds accessACL and defaultACL fields to tmpfs's inode
  • Allows system.posix_acl_access and system.posix_acl_default xattrs to set and retrieve POSIX ACLs
  • Updates tmpfs's stat implementation to account for the ACL in setting/retrieving a file's mode
  • Updates GenericCheckPermission to take an optional ACL. All non-tmpfs filesystems pass the nil ACL.
  • Updates tmpfs's tar save-and-restore logic to store the base64-encoded POSIX ACL xattrs in the tar header
  • Adds unit tests for POSIX ACL parsing/serialization
  • Adds integration tests for POSIX ACLs
  • Adds a container test to verify the tmpfs tar save/restore logic with ACLs. This required a new subcommand for test_app to set and fetch xattrs in the container

The motivation for POSIX ACLs is for journald (which uses POSIX ACLs to give non-root users access to their own systemctl --user services' logs). This commit is not actually sufficient to get this working -- we will need to plumb ACLs to overlayfs, too, which will be done in a follow-up commit.

The implementation is very similar to the implementation in Linux, although it is filesystem-specific rather than at the VFS layer (much like we store mode, uid, gid, etc at the FS layer currently). An optional access and default ACL is stored in each inode. If present, it is used for permission checks and is kept in sync with the mode. The mode is computed from the ACL when permissions are updated. If the ACL is simple enough to be stored equivalently as a mode, an ACL is not stored.

One limitation at the moment is that upon file creation, the process's umask is masked against the creation mode regardless of the presence of a default ACL, whereas Linux only masks against umask when not inheriting from a default ACL. Fixing this would require a fair bit of refactoring since umask isn't passed through to filesystems at all, and is instead masked with the creation mode at the syscall layer. This is not a security issue since the resulting permissions are always of equal-or-greater restrictiveness to those of Linux, but is tracked in #13688.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#13693 from relkochta:relkochta/posix-acls-tmpfs 0df3de9

@copybara-service copybara-service Bot added the exported Issue was exported automatically label Jul 28, 2026
Implements POSIX ACLs for gVisor's tmpfs. As a summary:

- Adds `accessACL` and `defaultACL` fields to tmpfs's inode
- Allows `system.posix_acl_access` and `system.posix_acl_default` xattrs to set and retrieve POSIX ACLs
- Updates tmpfs's stat implementation to account for the ACL in setting/retrieving a file's mode
- Updates `GenericCheckPermission` to take an optional ACL. All non-tmpfs filesystems pass the `nil` ACL.
- Updates tmpfs's tar save-and-restore logic to store the base64-encoded POSIX ACL xattrs in the tar header
- Adds unit tests for POSIX ACL parsing/serialization
- Adds integration tests for POSIX ACLs
- Adds a container test to verify the tmpfs tar save/restore logic with ACLs. This required a new subcommand for `test_app` to set and fetch xattrs in the container

The motivation for POSIX ACLs is for journald (which uses POSIX ACLs to give non-root users access to their own `systemctl --user` services' logs). This commit is not actually sufficient to get this working -- we will need to plumb ACLs to overlayfs, too, which will be done in a follow-up commit.

The implementation is very similar to the implementation in Linux, although it is filesystem-specific rather than at the VFS layer (much like we store `mode`, `uid`, `gid`, etc at the FS layer currently). An optional access and default ACL is stored in each inode. If present, it is used for permission checks and is kept in sync with the `mode`. The `mode` is computed from the ACL when permissions are updated. If the ACL is simple enough to be stored equivalently as a `mode`, an ACL is not stored.

One limitation at the moment is that upon file creation, the process's umask is masked against the creation mode regardless of the presence of a default ACL, whereas Linux only masks against umask when *not* inheriting from a default ACL. Fixing this would require a fair bit of refactoring since umask isn't passed through to filesystems at all, and is instead masked with the creation mode at the syscall layer. This is not a security issue since the resulting permissions are always of equal-or-greater restrictiveness to those of Linux, but is tracked in #13688.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#13693 from relkochta:relkochta/posix-acls-tmpfs 0df3de9
PiperOrigin-RevId: 955529312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant