seccomp: allow sched_setscheduler() with SCHED_IDLE policy
PATCH 1/1 seccomp: allow sched_setscheduler() with SCHED_IDLE policy
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
--- qemu-seccomp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
qemu-seccomp.c +10 -2
@@ -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; }
Signature · 1 line
2.18.0.129.ge3331758f1
Quoted 56 lines · Marc-André Lureau
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=1594456Signed-off-by Marc-André Lureau <[email protected]>--- qemu-seccomp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)qemu-seccomp.c +10
-2@@ -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; }Signature · 1 line
2.18.0.129.ge3331758f1
Patch looks safe enough for me. If everyone else is OK with this I'll send a pull-request tomorrow morning.
Daniel P. Berrangé
Reviewed-byQuoted 60 lines · Eduardo Otubo
Quoted 56 lines · Marc-André Lureau
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=1594456Signed-off-by Marc-André Lureau <[email protected]>--- qemu-seccomp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)qemu-seccomp.c +10
-2@@ -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; }Signature · 1 line
2.18.0.129.ge3331758f1Acked-by Eduardo Otubo <[email protected]>
Quoted 2 lines
Patch looks safe enough for me. If everyone else is OK with this I'll send a pull-request tomorrow morning.
Regards,
Daniel
Signature · 3 lines
|: 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 :|