All of lore.kernel.org
 help / color / mirror / Atom feed
* [Virtio-fs] [PATCH] virtiofsd: Add gettimeofday to the seccomp whitelist
@ 2019-07-30 21:50 Masayoshi Mizuma
  2019-07-31 15:04 ` Stefan Hajnoczi
  0 siblings, 1 reply; 4+ messages in thread
From: Masayoshi Mizuma @ 2019-07-30 21:50 UTC (permalink / raw)
  To: virtio-fs; +Cc: Masayoshi Mizuma

From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

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

>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.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 contrib/virtiofsd/seccomp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/virtiofsd/seccomp.c b/contrib/virtiofsd/seccomp.c
index ffb9f4c..cea4cc5 100644
--- a/contrib/virtiofsd/seccomp.c
+++ b/contrib/virtiofsd/seccomp.c
@@ -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),
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: Add gettimeofday to the seccomp whitelist
  2019-07-30 21:50 [Virtio-fs] [PATCH] virtiofsd: Add gettimeofday to the seccomp whitelist Masayoshi Mizuma
@ 2019-07-31 15:04 ` Stefan Hajnoczi
  2019-07-31 16:29   ` Dr. David Alan Gilbert
  2019-07-31 18:43   ` Masayoshi Mizuma
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2019-07-31 15:04 UTC (permalink / raw)
  To: Masayoshi Mizuma; +Cc: virtio-fs, Masayoshi Mizuma

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

On Tue, Jul 30, 2019 at 05:50:00PM -0400, Masayoshi Mizuma wrote:
> From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> 
> When I run fsstress on the virtio filesystem, virtiofsd sometimes
> exits abnormally because it receives SIGSYS.
> 
> >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.
> 
> Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> ---
>  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:

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: Add gettimeofday to the seccomp whitelist
  2019-07-31 15:04 ` Stefan Hajnoczi
@ 2019-07-31 16:29   ` Dr. David Alan Gilbert
  2019-07-31 18:43   ` Masayoshi Mizuma
  1 sibling, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert @ 2019-07-31 16:29 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: virtio-fs, Masayoshi Mizuma

* Stefan Hajnoczi (stefanha@redhat.com) wrote:
> On Tue, Jul 30, 2019 at 05:50:00PM -0400, Masayoshi Mizuma wrote:
> > From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > 
> > When I run fsstress on the virtio filesystem, virtiofsd sometimes
> > exits abnormally because it receives SIGSYS.
> > 
> > >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.
> > 
> > Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > ---
> >  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:
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Thanks,
Applied.



> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs@redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs

--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: Add gettimeofday to the seccomp whitelist
  2019-07-31 15:04 ` Stefan Hajnoczi
  2019-07-31 16:29   ` Dr. David Alan Gilbert
@ 2019-07-31 18:43   ` Masayoshi Mizuma
  1 sibling, 0 replies; 4+ messages in thread
From: Masayoshi Mizuma @ 2019-07-31 18:43 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: virtio-fs, Masayoshi Mizuma

On Wed, Jul 31, 2019 at 04:04:43PM +0100, Stefan Hajnoczi wrote:
> On Tue, Jul 30, 2019 at 05:50:00PM -0400, Masayoshi Mizuma wrote:
> > From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > 
> > When I run fsstress on the virtio filesystem, virtiofsd sometimes
> > exits abnormally because it receives SIGSYS.
> > 
> > >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.
> > 
> > Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > ---
> >  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.)

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().

> 
> The patch is fine though:
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Thank you so much!

- Masa


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-31 18:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30 21:50 [Virtio-fs] [PATCH] virtiofsd: Add gettimeofday to the seccomp whitelist Masayoshi Mizuma
2019-07-31 15:04 ` Stefan Hajnoczi
2019-07-31 16:29   ` Dr. David Alan Gilbert
2019-07-31 18:43   ` Masayoshi Mizuma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.