Skip to contentSkip to conversation

seccomp: fix killing of whole process instead of thread

PATCH In review Daniel P. Berrangé 3 participants 3 messages Sep 11, 2020 – Sep 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 seccomp: fix killing of whole process instead of thread

Back in 2018 we introduced support for killing the whole QEMU process instead of just one thread, when a seccomp rule is violated:

commit bda08a5764d470f101fa38635d30b41179a313e1
Author: Marc-André Lureau <[email protected]>
Date: Wed Aug 22 19:02:48 2018 +0200

seccomp: prefer SCMP_ACT_KILL_PROCESS if available

Fast forward a year and we introduced a patch to avoid killing the process for resource control syscalls tickled by Mesa.

commit 9a1565a03b79d80b236bc7cc2dbce52a2ef3a1b8
Author: Daniel P. Berrangé <[email protected]>
Date: Wed Mar 13 09:49:03 2019 +0000

seccomp: don't kill process for resource control syscalls

Unfortunately a logic bug effectively reverted the first commit mentioned so that we go back to only killing the thread, not the whole process.

---
 qemu-seccomp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qemu-seccomp.c +2 -1
index e0a1829b3d..8325ecb766 100644
@@ -136,8 +136,9 @@ static uint32_t qemu_seccomp_get_action(int set)
 
             if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
                 kill_process = 1;
+            } else {
+                kill_process = 0;
             }
-            kill_process = 0;
         }
         if (kill_process == 1) {
             return SCMP_ACT_KILL_PROCESS;
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Daniel P. Berrangé

Back in 2018 we introduced support for killing the whole QEMU process instead of just one thread, when a seccomp rule is violated:

commit bda08a5764d470f101fa38635d30b41179a313e1
Author: Marc-André Lureau <[email protected]>
Date: Wed Aug 22 19:02:48 2018 +0200

seccomp: prefer SCMP_ACT_KILL_PROCESS if available

Fast forward a year and we introduced a patch to avoid killing the process for resource control syscalls tickled by Mesa.

commit 9a1565a03b79d80b236bc7cc2dbce52a2ef3a1b8
Author: Daniel P. Berrangé <[email protected]>
Date: Wed Mar 13 09:49:03 2019 +0000

seccomp: don't kill process for resource control syscalls

Quoted 8 lines

Unfortunately a logic bug effectively reverted the first commit mentioned so that we go back to only killing the thread, not the whole process.

---
 qemu-seccomp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Acked-by on v1 1/1
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 45 lines · Daniel P. Berrange

Back in 2018 we introduced support for killing the whole QEMU process instead of just one thread, when a seccomp rule is violated:

commit bda08a5764d470f101fa38635d30b41179a313e1
Author: Marc-André Lureau <[email protected]>
Date: Wed Aug 22 19:02:48 2018 +0200

seccomp: prefer SCMP_ACT_KILL_PROCESS if available

Fast forward a year and we introduced a patch to avoid killing the process for resource control syscalls tickled by Mesa.

commit 9a1565a03b79d80b236bc7cc2dbce52a2ef3a1b8
Author: Daniel P. Berrangé <[email protected]>
Date: Wed Mar 13 09:49:03 2019 +0000

seccomp: don't kill process for resource control syscalls

Unfortunately a logic bug effectively reverted the first commit mentioned so that we go back to only killing the thread, not the whole process.

---
 qemu-seccomp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qemu-seccomp.c +2 -1
index e0a1829b3d..8325ecb766 100644
@@ -136,8 +136,9 @@ static uint32_t qemu_seccomp_get_action(int set)
 
             if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
                 kill_process = 1;
+            } else {
+                kill_process = 0;
             }
-            kill_process = 0;
         }
         if (kill_process == 1) {
             return SCMP_ACT_KILL_PROCESS;
Signature · 1 line
2.26.2