Skip to contentSkip to conversation

Enable seccomp on MIPS

PATCH In review James Hogan 2 participants 5 messages Apr 8, 2016 – Apr 12, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover Enable seccomp on MIPS

These patches enable seccomp sandboxing on MIPS.

libseccomp has supported MIPS since 2.2.0, but cacheflush isn't included in the whitelist until libseccomp 2.2.3 since thats when it was enabled for ARM. The first patch fixes that so that it will work with MIPS right back to 2.2.0.

Finally the second patch enables seccomp in the configure script for MIPS since libseccomp 2.2.0.

Incidentally, when cacheflush(2) was being used prior to it appearing in the whitelist, I noticed that only a single thread was being killed by SCMP_ACT_KILL (which the man page also confirms) rather than the whole process, simply resulting in a lockup, and making it tricky to debug since it wasn't immediately obvious what had happened (same thing can be made to happen on x86 if e.g. read syscall is disallowed).

Should we be using the apparently more helpful SCMP_ACT_TRAP instead of SCMP_ACT_KILL, or is that considered less secure? It would seem preferable if we could kill the whole process in a recognisable way instead of hanging it.

Changes in v2:
- Added Peter's comment in patch 1.

James Hogan (2):
seccomp: Whitelist cacheflush since 2.2.0 not 2.2.3
configure: Enable seccomp sandbox for MIPS

 configure      | 3 +++
 qemu-seccomp.c | 8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.10
#1 lore raw

PATCH v2 1/2 seccomp: Whitelist cacheflush since 2.2.0 not 2.2.3

The cacheflush system call (found on MIPS and ARM) has been included in the libseccomp header since 2.2.0, so include it back to that version. Previously it was only enabled since 2.2.3 since that is when it was enabled properly for ARM.

This will allow seccomp support to be enabled for MIPS back to libseccomp 2.2.0.

---
Changes in v2:
- Added Peter's comment

---
 qemu-seccomp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
qemu-seccomp.c +5 -3
index 2866e3c2a660..138ee022a8fe 100644
@@ -16,11 +16,13 @@
 #include <seccomp.h>
 #include "sysemu/seccomp.h"
 
+/* For some architectures (notably ARM) cacheflush is not supported until
+ * libseccomp 2.2.3, but configure enforces that we are using a more recent
+ * version on those hosts, so it is OK for this check to be less strict.
+ */
 #if SCMP_VER_MAJOR >= 3
   #define HAVE_CACHEFLUSH
-#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR >= 3
-  #define HAVE_CACHEFLUSH
-#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR == 2 && SCMP_VER_MICRO >= 3
+#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR >= 2
   #define HAVE_CACHEFLUSH
 #endif
 
Signature · 1 line
2.4.10
#3 lore raw

PATCH v2 2/2 configure: Enable seccomp sandbox for MIPS

In reply to James Hogan

Enable seccomp on MIPS since libseccomp version 2.2.0 when MIPS support was first added.

---
 configure | 3 +++
 1 file changed, 3 insertions(+)
configure +3 -0
index 5db29f0245ae..f1c307bfc69c 100755
@@ -1872,6 +1872,9 @@ if test "$seccomp" != "no" ; then
     i386|x86_64)
         libseccomp_minver="2.1.0"
         ;;
+    mips)
+        libseccomp_minver="2.2.0"
+        ;;
     arm|aarch64)
         libseccomp_minver="2.2.3"
         ;;
Signature · 1 line
2.4.10
Acked-by on v2 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] configure: Enable seccomp sandbox for MIPS

Quoted 28 lines · James Hogan

Enable seccomp on MIPS since libseccomp version 2.2.0 when MIPS support was first added.

---
 configure | 3 +++
 1 file changed, 3 insertions(+)
configure +3 -0
index 5db29f0245ae..f1c307bfc69c 100755
@@ -1872,6 +1872,9 @@ if test "$seccomp" != "no" ; then
     i386|x86_64)
         libseccomp_minver="2.1.0"
         ;;
+    mips)
+        libseccomp_minver="2.2.0"
+        ;;
     arm|aarch64)
         libseccomp_minver="2.2.3"
         ;;
Signature · 1 line
2.4.10
Signature · 2 lines
Eduardo Otubo
ProfitBricks GmbH
Acked-by on v2 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] seccomp: Whitelist cacheflush since 2.2.0 not 2.2.3

In reply to James Hogan
Quoted 43 lines · James Hogan

The cacheflush system call (found on MIPS and ARM) has been included in the libseccomp header since 2.2.0, so include it back to that version. Previously it was only enabled since 2.2.3 since that is when it was enabled properly for ARM.

This will allow seccomp support to be enabled for MIPS back to libseccomp 2.2.0.

---
Changes in v2:
- Added Peter's comment

---
 qemu-seccomp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
qemu-seccomp.c +5 -3
index 2866e3c2a660..138ee022a8fe 100644
@@ -16,11 +16,13 @@
 #include <seccomp.h>
 #include "sysemu/seccomp.h"
 
+/* For some architectures (notably ARM) cacheflush is not supported until
+ * libseccomp 2.2.3, but configure enforces that we are using a more recent
+ * version on those hosts, so it is OK for this check to be less strict.
+ */
 #if SCMP_VER_MAJOR >= 3
   #define HAVE_CACHEFLUSH
-#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR >= 3
-  #define HAVE_CACHEFLUSH
-#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR == 2 && SCMP_VER_MICRO >= 3
+#elif SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR >= 2
   #define HAVE_CACHEFLUSH
 #endif
 
Signature · 1 line
2.4.10

(if nothing else comes up for the seccomp queue this week, I'll prepare a pull request by Friday. Thanks for the contribution)

Signature · 2 lines
Eduardo Otubo
ProfitBricks GmbH