Skip to content

tmpfs: implement POSIX ACLs#13693

Open
relkochta wants to merge 1 commit into
google:masterfrom
relkochta:relkochta/posix-acls-tmpfs
Open

tmpfs: implement POSIX ACLs#13693
relkochta wants to merge 1 commit into
google:masterfrom
relkochta:relkochta/posix-acls-tmpfs

Conversation

@relkochta

Copy link
Copy Markdown
Collaborator

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant