crosvm/seccomp/arm/fs_device.policy
Chirantan Ekbote 44336b9131 devices: fs: Fix posix acl handling
Posix acls are a truly incredible example of API design.  The presence
of a default posix acl in a directory completely changes the meaning of
the `mode` parameter for all system call that create inodes.  However,
this new behavior only applies when the inode is first created and not
for any subsequent operations that use the mode, like fchmod.

When a directory has a default posix acl, all inodes created in that
directory get the permissions specified in the default acl.  The mode
parameter is treated like a umask where any permissions allowed by the
default acl that are not allowed by the mode parameter are blocked.  The
actual umask is ignored in this case.

So to handle this properly we need to set FUSE_DONT_MASK to prevent the
kernel driver from preemptively applying the umask.  Then we have to
check if the parent directory has a default posix acl and only apply the
umask to the mode if it does not.  This also means that we cannot use
`mkdtemp` because that always creates directories with a mode of 0o700
and since the default posix acl calculation only applies on creation and
not on later operations, we need to apply the proper mode in the very
beginning.

BUG=b:159285544,b:152806644
TEST=vm.Virtiofs.  Use a test program to create files/directories in
     directories that have a default acl and ones that don't, and verify
     that the mode is correctly set after creation

Change-Id: Ieca8ac9db391feebe5719630c5f3b57b04b71533
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2260253
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
2020-06-29 10:14:42 +00:00

44 lines
No EOL
829 B
Text

# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@include /usr/share/policy/crosvm/common_device.policy
copy_file_range: 1
fallocate: 1
fchmod: 1
fchmodat: 1
fchown32: 1
fchownat: 1
fdatasync: 1
lgetxattr: 1
lsetxattr: 1
llistxattr: 1
lremovexattr: 1
fstatat64: 1
fstatfs64: 1
fsync: 1
ftruncate64: 1
getdents64: 1
getegid32: 1
geteuid32: 1
getrandom: 1
ioctl: arg1 == FS_IOC_GET_ENCRYPTION_POLICY || arg1 == FS_IOC_SET_ENCRYPTION_POLICY || arg1 == FS_IOC_FSGETXATTR || arg1 == FS_IOC_FSSETXATTR
linkat: 1
_llseek: 1
mkdir: 1
mkdirat: 1
mknodat: 1
open: return ENOENT
openat: 1
preadv: 1
pwritev: 1
readlinkat: 1
renameat2: 1
setresgid32: 1
setresuid32: 1
statx: 1
symlinkat: 1
umask: 1
unlinkat: 1
utimensat: 1