diff options
author | Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> | 2020-02-27 14:59:27 +0900 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2020-03-03 15:13:24 +0000 |
commit | bdfd66788349acc43cd3f1298718ad491663cfcc (patch) | |
tree | b434c62919409565efd51d4840291abed6150857 /tools/virtiofsd/seccomp.c | |
parent | 16e15a73089102c3d8846792d514e769300fcc3c (diff) |
virtiofsd: Fix xattr operations
Current virtiofsd has problems about xattr operations and
they does not work properly for directory/symlink/special file.
The fundamental cause is that virtiofsd uses openat() + f...xattr()
systemcalls for xattr operation but we should not open symlink/special
file in the daemon. Therefore the function is restricted.
Fix this problem by:
1. during setup of each thread, call unshare(CLONE_FS)
2. in xattr operations (i.e. lo_getxattr), if inode is not a regular
file or directory, use fchdir(proc_loot_fd) + ...xattr() +
fchdir(root.fd) instead of openat() + f...xattr()
(Note: for a regular file/directory openat() + f...xattr()
is still used for performance reason)
With this patch, xfstests generic/062 passes on virtiofs.
This fix is suggested by Miklos Szeredi and Stefan Hajnoczi.
The original discussion can be found here:
https://www.redhat.com/archives/virtio-fs/2019-October/msg00046.html
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Message-Id: <20200227055927.24566-3-misono.tomohiro@jp.fujitsu.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'tools/virtiofsd/seccomp.c')
-rw-r--r-- | tools/virtiofsd/seccomp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/virtiofsd/seccomp.c b/tools/virtiofsd/seccomp.c index 2d9d4a7ec0..bd9e7b083c 100644 --- a/tools/virtiofsd/seccomp.c +++ b/tools/virtiofsd/seccomp.c @@ -41,6 +41,7 @@ static const int syscall_whitelist[] = { SCMP_SYS(exit), SCMP_SYS(exit_group), SCMP_SYS(fallocate), + SCMP_SYS(fchdir), SCMP_SYS(fchmodat), SCMP_SYS(fchownat), SCMP_SYS(fcntl), @@ -62,7 +63,9 @@ static const int syscall_whitelist[] = { SCMP_SYS(getpid), SCMP_SYS(gettid), SCMP_SYS(gettimeofday), + SCMP_SYS(getxattr), SCMP_SYS(linkat), + SCMP_SYS(listxattr), SCMP_SYS(lseek), SCMP_SYS(madvise), SCMP_SYS(mkdirat), @@ -85,6 +88,7 @@ static const int syscall_whitelist[] = { SCMP_SYS(recvmsg), SCMP_SYS(renameat), SCMP_SYS(renameat2), + SCMP_SYS(removexattr), SCMP_SYS(rt_sigaction), SCMP_SYS(rt_sigprocmask), SCMP_SYS(rt_sigreturn), @@ -98,10 +102,12 @@ static const int syscall_whitelist[] = { SCMP_SYS(setresuid32), #endif SCMP_SYS(set_robust_list), + SCMP_SYS(setxattr), SCMP_SYS(symlinkat), SCMP_SYS(time), /* Rarely needed, except on static builds */ SCMP_SYS(tgkill), SCMP_SYS(unlinkat), + SCMP_SYS(unshare), SCMP_SYS(utimensat), SCMP_SYS(write), SCMP_SYS(writev), |