tmpfs: implement POSIX ACLs#13693
Open
relkochta wants to merge 1 commit into
Open
Conversation
Implements POSIX ACLs for gVisor's tmpfs. As a summary: - Adds `acl` 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements POSIX ACLs for gVisor's tmpfs. As a summary:
aclanddefaultACLfields to tmpfs's inodesystem.posix_acl_accessandsystem.posix_acl_defaultxattrs to set and retrieve POSIX ACLsGenericCheckPermissionto take an optional ACL. All non-tmpfs filesystems pass thenilACL.test_appto set and fetch xattrs in the containerThe motivation for POSIX ACLs is for journald (which uses POSIX ACLs to give non-root users access to their own
systemctl --userservices' 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 themode. Themodeis computed from the ACL when permissions are updated. If the ACL is simple enough to be stored equivalently as amode, 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