Skip to contentSkip to conversation

virtiofsd: Add gettimeofday to the seccomp whitelist

PATCH In review Masayoshi Mizuma 3 participants 4 messages Jul 30, 2019 – Jul 31, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtiofsd: Add gettimeofday to the seccomp whitelist

From: Masayoshi Mizuma <[email protected]>

When I run fsstress on the virtio filesystem, virtiofsd sometimes exits abnormally because it receives SIGSYS.

Quoted 1 line

From strace:

195852 15:07:47.799331 read(8, "\1\0\0\0\0\0\0\0", 8) = 8 <0.000011> 195852 15:07:47.799379 gettimeofday( <unfinished ...> 195852 15:07:53.354340 <... gettimeofday resumed> <unfinished ...>) = ? 195852 15:07:53.400243 +++ killed by SIGSYS (core dumped) +++

That is because virtiofsd calls gettimeofday() system call but the system call isn't in the seccomp whitelist.

virtiofsd doesn't call gettimeofday() directly. glib library function may call g_get_current_time() and g_get_current_time() calls the system call.

Add gettimeofday() to the seccomp whitelist.

---
 contrib/virtiofsd/seccomp.c | 1 +
 1 file changed, 1 insertion(+)
contrib/virtiofsd/seccomp.c +1 -0
index ffb9f4c..cea4cc5 100644
@@ -44,6 +44,7 @@ static const int syscall_whitelist[] = {
 	SCMP_SYS(geteuid),
 	SCMP_SYS(getpid),
 	SCMP_SYS(gettid),
+	SCMP_SYS(gettimeofday),
 	SCMP_SYS(linkat),
 	SCMP_SYS(lseek),
 	SCMP_SYS(madvise),
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Masayoshi Mizuma

From: Masayoshi Mizuma <[email protected]>

When I run fsstress on the virtio filesystem, virtiofsd sometimes exits abnormally because it receives SIGSYS.

Quoted 1 line

From strace:

195852 15:07:47.799331 read(8, "\1\0\0\0\0\0\0\0", 8) = 8 <0.000011> 195852 15:07:47.799379 gettimeofday( <unfinished ...> 195852 15:07:53.354340 <... gettimeofday resumed> <unfinished ...>) = ? 195852 15:07:53.400243 +++ killed by SIGSYS (core dumped) +++

That is because virtiofsd calls gettimeofday() system call but the system call isn't in the seccomp whitelist.

virtiofsd doesn't call gettimeofday() directly. glib library function may call g_get_current_time() and g_get_current_time() calls the system call.

Quoted 6 lines

Add gettimeofday() to the seccomp whitelist.

---
 contrib/virtiofsd/seccomp.c | 1 +
 1 file changed, 1 insertion(+)

Have you checked that your guest is using the vdso gettimeofday() implementation? gettimeofday() is implemented in userspace without a syscall using vdso to improve performance. If your guest isn't using it then performance will be worse. (There is a fallback code path in the vdso that invokes the syscall but I'm not sure it is taken in normal cases.)

The patch is fine though:

#2 lore raw
Quoted 33 lines · * Stefan Hajnoczi ([email protected]) wrote:
Quoted 18 lines · Masayoshi Mizuma

From: Masayoshi Mizuma <[email protected]>

When I run fsstress on the virtio filesystem, virtiofsd sometimes exits abnormally because it receives SIGSYS.

Quoted 1 line

From strace:

195852 15:07:47.799331 read(8, "\1\0\0\0\0\0\0\0", 8) = 8 <0.000011> 195852 15:07:47.799379 gettimeofday( <unfinished ...> 195852 15:07:53.354340 <... gettimeofday resumed> <unfinished ...>) = ? 195852 15:07:53.400243 +++ killed by SIGSYS (core dumped) +++

That is because virtiofsd calls gettimeofday() system call but the system call isn't in the seccomp whitelist.

virtiofsd doesn't call gettimeofday() directly. glib library function may call g_get_current_time() and g_get_current_time() calls the system call.

Quoted 6 lines

Add gettimeofday() to the seccomp whitelist.

---
 contrib/virtiofsd/seccomp.c | 1 +
 1 file changed, 1 insertion(+)

Have you checked that your guest is using the vdso gettimeofday() implementation? gettimeofday() is implemented in userspace without a syscall using vdso to improve performance. If your guest isn't using it then performance will be worse. (There is a fallback code path in the vdso that invokes the syscall but I'm not sure it is taken in normal cases.)

Quoted 3 lines

The patch is fine though:

Thanks,
Applied.

Quoted 4 lines

_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#3 lore raw
In reply to Stefan Hajnoczi
Quoted 26 lines · Stefan Hajnoczi
Quoted 18 lines · Masayoshi Mizuma

From: Masayoshi Mizuma <[email protected]>

When I run fsstress on the virtio filesystem, virtiofsd sometimes exits abnormally because it receives SIGSYS.

Quoted 1 line

From strace:

195852 15:07:47.799331 read(8, "\1\0\0\0\0\0\0\0", 8) = 8 <0.000011> 195852 15:07:47.799379 gettimeofday( <unfinished ...> 195852 15:07:53.354340 <... gettimeofday resumed> <unfinished ...>) = ? 195852 15:07:53.400243 +++ killed by SIGSYS (core dumped) +++

That is because virtiofsd calls gettimeofday() system call but the system call isn't in the seccomp whitelist.

virtiofsd doesn't call gettimeofday() directly. glib library function may call g_get_current_time() and g_get_current_time() calls the system call.

Quoted 6 lines

Add gettimeofday() to the seccomp whitelist.

---
 contrib/virtiofsd/seccomp.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 6 lines

Have you checked that your guest is using the vdso gettimeofday() implementation? gettimeofday() is implemented in userspace without a syscall using vdso to improve performance. If your guest isn't using it then performance will be worse. (There is a fallback code path in the vdso that invokes the syscall but I'm not sure it is taken in normal cases.)

Yes, my guest is using the vdso gettimeofday().
I'm not sure why virtiofsd calls gettimeofday(), probably the glib library function calls g_get_current_time() and the glib function calls gettimeofday().

Quoted 4 lines

The patch is fine though:

Thank you so much!

- Masa