qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] seccomp: allow sched_setscheduler() with SCHED_IDLE policy
@ 2018-07-10 14:55 Marc-André Lureau
  2018-07-11 14:48 ` Eduardo Otubo
  0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2018-07-10 14:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: eskultet, kraxel, berrange, gschafer, Marc-André Lureau,
	Eduardo Otubo

Current and upcoming mesa releases rely on a shader disk cash. It uses
a thread job queue with low priority, set with
sched_setscheduler(SCHED_IDLE). However, that syscall is rejected by
the "resourcecontrol" seccomp qemu filter.

Since it should be safe to allow lowering thread priority, let's allow
scheduling thread to idle policy.

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1594456

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qemu-seccomp.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/qemu-seccomp.c b/qemu-seccomp.c
index 148e4c6f24..9cd8eb9499 100644
--- a/qemu-seccomp.c
+++ b/qemu-seccomp.c
@@ -34,6 +34,12 @@
 struct QemuSeccompSyscall {
     int32_t num;
     uint8_t set;
+    uint8_t narg;
+    const struct scmp_arg_cmp *arg_cmp;
+};
+
+const struct scmp_arg_cmp sched_setscheduler_arg[] = {
+    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
 };
 
 static const struct QemuSeccompSyscall blacklist[] = {
@@ -92,7 +98,8 @@ static const struct QemuSeccompSyscall blacklist[] = {
     { SCMP_SYS(setpriority),            QEMU_SECCOMP_SET_RESOURCECTL },
     { SCMP_SYS(sched_setparam),         QEMU_SECCOMP_SET_RESOURCECTL },
     { SCMP_SYS(sched_getparam),         QEMU_SECCOMP_SET_RESOURCECTL },
-    { SCMP_SYS(sched_setscheduler),     QEMU_SECCOMP_SET_RESOURCECTL },
+    { SCMP_SYS(sched_setscheduler),     QEMU_SECCOMP_SET_RESOURCECTL,
+      ARRAY_SIZE(sched_setscheduler_arg), sched_setscheduler_arg },
     { SCMP_SYS(sched_getscheduler),     QEMU_SECCOMP_SET_RESOURCECTL },
     { SCMP_SYS(sched_setaffinity),      QEMU_SECCOMP_SET_RESOURCECTL },
     { SCMP_SYS(sched_getaffinity),      QEMU_SECCOMP_SET_RESOURCECTL },
@@ -118,7 +125,8 @@ static int seccomp_start(uint32_t seccomp_opts)
             continue;
         }
 
-        rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, blacklist[i].num, 0);
+        rc = seccomp_rule_add_array(ctx, SCMP_ACT_KILL, blacklist[i].num,
+                                    blacklist[i].narg, blacklist[i].arg_cmp);
         if (rc < 0) {
             goto seccomp_return;
         }
-- 
2.18.0.129.ge3331758f1

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

* Re: [Qemu-devel] [PATCH] seccomp: allow sched_setscheduler() with SCHED_IDLE policy
  2018-07-10 14:55 [Qemu-devel] [PATCH] seccomp: allow sched_setscheduler() with SCHED_IDLE policy Marc-André Lureau
@ 2018-07-11 14:48 ` Eduardo Otubo
  2018-07-16  9:35   ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Otubo @ 2018-07-11 14:48 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, eskultet, kraxel, berrange, gschafer

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

On 10/07/2018 - 16:55:57, Marc-André Lureau wrote:
> Current and upcoming mesa releases rely on a shader disk cash. It uses
> a thread job queue with low priority, set with
> sched_setscheduler(SCHED_IDLE). However, that syscall is rejected by
> the "resourcecontrol" seccomp qemu filter.
> 
> Since it should be safe to allow lowering thread priority, let's allow
> scheduling thread to idle policy.
> 
> Related to:
> https://bugzilla.redhat.com/show_bug.cgi?id=1594456
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qemu-seccomp.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/qemu-seccomp.c b/qemu-seccomp.c
> index 148e4c6f24..9cd8eb9499 100644
> --- a/qemu-seccomp.c
> +++ b/qemu-seccomp.c
> @@ -34,6 +34,12 @@
>  struct QemuSeccompSyscall {
>      int32_t num;
>      uint8_t set;
> +    uint8_t narg;
> +    const struct scmp_arg_cmp *arg_cmp;
> +};
> +
> +const struct scmp_arg_cmp sched_setscheduler_arg[] = {
> +    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
>  };
>  
>  static const struct QemuSeccompSyscall blacklist[] = {
> @@ -92,7 +98,8 @@ static const struct QemuSeccompSyscall blacklist[] = {
>      { SCMP_SYS(setpriority),            QEMU_SECCOMP_SET_RESOURCECTL },
>      { SCMP_SYS(sched_setparam),         QEMU_SECCOMP_SET_RESOURCECTL },
>      { SCMP_SYS(sched_getparam),         QEMU_SECCOMP_SET_RESOURCECTL },
> -    { SCMP_SYS(sched_setscheduler),     QEMU_SECCOMP_SET_RESOURCECTL },
> +    { SCMP_SYS(sched_setscheduler),     QEMU_SECCOMP_SET_RESOURCECTL,
> +      ARRAY_SIZE(sched_setscheduler_arg), sched_setscheduler_arg },
>      { SCMP_SYS(sched_getscheduler),     QEMU_SECCOMP_SET_RESOURCECTL },
>      { SCMP_SYS(sched_setaffinity),      QEMU_SECCOMP_SET_RESOURCECTL },
>      { SCMP_SYS(sched_getaffinity),      QEMU_SECCOMP_SET_RESOURCECTL },
> @@ -118,7 +125,8 @@ static int seccomp_start(uint32_t seccomp_opts)
>              continue;
>          }
>  
> -        rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, blacklist[i].num, 0);
> +        rc = seccomp_rule_add_array(ctx, SCMP_ACT_KILL, blacklist[i].num,
> +                                    blacklist[i].narg, blacklist[i].arg_cmp);
>          if (rc < 0) {
>              goto seccomp_return;
>          }
> -- 
> 2.18.0.129.ge3331758f1
> 

Acked-by: Eduardo Otubo <otubo@redhat.com>

Patch looks safe enough for me. If everyone else is OK with this I'll send a
pull-request tomorrow morning.

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

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

* Re: [Qemu-devel] [PATCH] seccomp: allow sched_setscheduler() with SCHED_IDLE policy
  2018-07-11 14:48 ` Eduardo Otubo
@ 2018-07-16  9:35   ` Daniel P. Berrangé
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2018-07-16  9:35 UTC (permalink / raw)
  To: Eduardo Otubo
  Cc: Marc-André Lureau, qemu-devel, eskultet, kraxel, gschafer

On Wed, Jul 11, 2018 at 04:48:55PM +0200, Eduardo Otubo wrote:
> On 10/07/2018 - 16:55:57, Marc-André Lureau wrote:
> > Current and upcoming mesa releases rely on a shader disk cash. It uses
> > a thread job queue with low priority, set with
> > sched_setscheduler(SCHED_IDLE). However, that syscall is rejected by
> > the "resourcecontrol" seccomp qemu filter.
> > 
> > Since it should be safe to allow lowering thread priority, let's allow
> > scheduling thread to idle policy.
> > 
> > Related to:
> > https://bugzilla.redhat.com/show_bug.cgi?id=1594456
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  qemu-seccomp.c | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/qemu-seccomp.c b/qemu-seccomp.c
> > index 148e4c6f24..9cd8eb9499 100644
> > --- a/qemu-seccomp.c
> > +++ b/qemu-seccomp.c
> > @@ -34,6 +34,12 @@
> >  struct QemuSeccompSyscall {
> >      int32_t num;
> >      uint8_t set;
> > +    uint8_t narg;
> > +    const struct scmp_arg_cmp *arg_cmp;
> > +};
> > +
> > +const struct scmp_arg_cmp sched_setscheduler_arg[] = {
> > +    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
> >  };
> >  
> >  static const struct QemuSeccompSyscall blacklist[] = {
> > @@ -92,7 +98,8 @@ static const struct QemuSeccompSyscall blacklist[] = {
> >      { SCMP_SYS(setpriority),            QEMU_SECCOMP_SET_RESOURCECTL },
> >      { SCMP_SYS(sched_setparam),         QEMU_SECCOMP_SET_RESOURCECTL },
> >      { SCMP_SYS(sched_getparam),         QEMU_SECCOMP_SET_RESOURCECTL },
> > -    { SCMP_SYS(sched_setscheduler),     QEMU_SECCOMP_SET_RESOURCECTL },
> > +    { SCMP_SYS(sched_setscheduler),     QEMU_SECCOMP_SET_RESOURCECTL,
> > +      ARRAY_SIZE(sched_setscheduler_arg), sched_setscheduler_arg },
> >      { SCMP_SYS(sched_getscheduler),     QEMU_SECCOMP_SET_RESOURCECTL },
> >      { SCMP_SYS(sched_setaffinity),      QEMU_SECCOMP_SET_RESOURCECTL },
> >      { SCMP_SYS(sched_getaffinity),      QEMU_SECCOMP_SET_RESOURCECTL },
> > @@ -118,7 +125,8 @@ static int seccomp_start(uint32_t seccomp_opts)
> >              continue;
> >          }
> >  
> > -        rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, blacklist[i].num, 0);
> > +        rc = seccomp_rule_add_array(ctx, SCMP_ACT_KILL, blacklist[i].num,
> > +                                    blacklist[i].narg, blacklist[i].arg_cmp);
> >          if (rc < 0) {
> >              goto seccomp_return;
> >          }
> > -- 
> > 2.18.0.129.ge3331758f1
> > 
> 
> Acked-by: Eduardo Otubo <otubo@redhat.com>
> 
> Patch looks safe enough for me. If everyone else is OK with this I'll send a
> pull-request tomorrow morning.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>



Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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

end of thread, other threads:[~2018-07-16  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-10 14:55 [Qemu-devel] [PATCH] seccomp: allow sched_setscheduler() with SCHED_IDLE policy Marc-André Lureau
2018-07-11 14:48 ` Eduardo Otubo
2018-07-16  9:35   ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).