virtiofsd: Add pread64() to seccomp list for posix_fallocate()
PATCH 1/1 virtiofsd: Add pread64() to seccomp list for posix_fallocate()
I test virtiofs with NFS 4.0 as backend and notice that fallocate causes system hang (kernel: 5.4-rc1, qemu: virtio-fs-dev branch):
$ mount -t virtiofs myfs /mnt $ dd if=/dev/urandom bs=1000 seek=1 count=1 of=/mnt/file $ fallocate -l 2000 /mnt/file # system hang
This is because:
1. virtiofs supports fallocate syscall while NFS 4.0 does not.
2. virtiofsd uses posix_fallocate() and it fallbacks to pread64()/ pwrite64() sequence to reserve blocks if fallocate syscall is not available.
3. pread64() syscall is prohibited by seccomp and virtiofsd thread is killed by SIGSYS.
So, just add pread64() to seccomp white list to fix this problem.
--- contrib/virtiofsd/seccomp.c | 1 + 1 file changed, 1 insertion(+)
contrib/virtiofsd/seccomp.c +1 -0
@@ -61,6 +61,7 @@ static const int syscall_whitelist[] = {SCMP_SYS (ppoll),SCMP_SYS (prctl),/* TODO restrict to just PR_SET_NAME? */ SCMP_SYS (preadv), +SCMP_SYS (pread64),SCMP_SYS (pwritev),SCMP_SYS (pwrite64), SCMP_SYS(read),
Signature · 1 line
2.21.0
Quoted 14 lines · * Misono Tomohiro ([email protected]) wrote:
I test virtiofs with NFS 4.0 as backend and notice that fallocate causes system hang (kernel: 5.4-rc1, qemu: virtio-fs-dev branch):
$ mount -t virtiofs myfs /mnt $ dd if=/dev/urandom bs=1000 seek=1 count=1 of=/mnt/file $ fallocate -l 2000 /mnt/file # system hangThis is because:
1. virtiofs supports fallocate syscall while NFS 4.0 does not.
2. virtiofsd usesposix_fallocate()and it fallbacks to pread64()/pwrite64()sequence to reserve blocks if fallocate syscall is not available.
3.pread64()syscall is prohibited by seccomp and virtiofsd thread is killed by SIGSYS.
Quoted 3 lines
So, just add
pread64()to seccomp white list to fix this problem.Signed-off-by Misono Tomohiro <[email protected]>
Thanks, I've squashed this into our seccomp commit.
(It'll be a little while before I push it out, I need to finish a tidyup I'm doing).
Dave
Quoted 23 lines
--- contrib/virtiofsd/seccomp.c | 1 + 1 file changed, 1 insertion(+)contrib/virtiofsd/seccomp.c +1
-0@@ -61,6 +61,7 @@ static const int syscall_whitelist[] = {SCMP_SYS (ppoll),SCMP_SYS (prctl),/* TODO restrict to just PR_SET_NAME? */ SCMP_SYS (preadv), +SCMP_SYS (pread64),SCMP_SYS (pwritev),SCMP_SYS (pwrite64), SCMP_SYS(read),Signature · 6 lines
2.21.0 _______________________________________________ Virtio-fs mailing list [email protected] https://www.redhat.com/mailman/listinfo/virtio-fs
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK