You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2019/02/12 19:41:07 UTC

[mesos] 06/09: Added `--enable-launcher-sealing` compiler flag.

This is an automated email from the ASF dual-hosted git repository.

gilbert pushed a commit to branch 1.5.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit d07fbdf0e320f53cff7f0aa22b4d4d5a69108182
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Mon Feb 11 12:51:27 2019 -0800

    Added `--enable-launcher-sealing` compiler flag.
    
    This flag enables sealing of launcher binary during initialization of
    Mesos containerizer. It's disabled by default because sealing requires
    Linux kernel 3.17+.
    
    Review: https://reviews.apache.org/r/69949/
    (cherry picked from commit c97d50e2b0b3bdbcb6dde58395a21c819d56194a)
---
 configure.ac             | 31 +++++++++++++++++++++++++++++++
 src/CMakeLists.txt       |  1 -
 src/Makefile.am          | 13 +++++++++++--
 src/tests/CMakeLists.txt |  1 -
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 91942c6..df92b6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,6 +225,17 @@ AC_ARG_ENABLE([java],
                              [don't build Java bindings]),
               [], [enable_java=yes])
 
+AC_ARG_ENABLE([launcher_sealing],
+              AS_HELP_STRING([--enable-launcher-sealing],
+                             [Enables sealing of launcher binary during
+                              initialization of Mesos containerizer.
+                              A copy of launcher's binary is cloned into
+                              memory and sealed to prevent overwriting of
+                              launcher's executable by containers.
+                              This is a Linux-specific feature and requires
+                              the support of memfd by the kernel.]),
+                             [], [enable_launcher_sealing=no])
+
 AC_ARG_ENABLE([libevent],
               AS_HELP_STRING([--enable-libevent],
                              [use libevent instead of libev]),
@@ -1303,6 +1314,26 @@ AM_CONDITIONAL([WITH_BUNDLED_LEVELDB],
                [test "x$with_bundled_leveldb" = "xyes"])
 
 
+# Check if we should use containerizer launcher sealing.
+AC_MSG_CHECKING([whether to enable launcher sealing])
+AC_MSG_RESULT([$enable_launcher_sealing])
+
+AS_IF([test "x$enable_launcher_sealing" = "xyes"], [
+  # We only support launcher sealing on Linux.
+  AS_IF([test "$OS_NAME" = "linux"],
+        [],
+        [AC_MSG_ERROR([no launcher sealing support on $OS_NAME
+-------------------------------------------------------------------
+Launcher sealing is only supported on Linux.
+-------------------------------------------------------------------
+  ])])
+
+  AC_DEFINE([ENABLE_LAUNCHER_SEALING])
+])
+
+AM_CONDITIONAL([ENABLE_LAUNCHER_SEALING], [test "x$enable_launcher_sealing" = "xyes"])
+
+
 # Check if libevent prefix path was provided, and if so, add it to
 # the CPPFLAGS and LDFLAGS with respective /include and /lib path
 # suffixes.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c4adfdf..6532308 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -243,7 +243,6 @@ set(LINUX_SRC
   linux/fs.cpp
   linux/ldcache.cpp
   linux/ldd.cpp
-  linux/memfd.cpp
   linux/ns.cpp
   linux/perf.cpp
   linux/systemd.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ac63e3..34f0d86 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1308,7 +1308,6 @@ MESOS_LINUX_FILES =									\
   linux/fs.cpp										\
   linux/ldcache.cpp									\
   linux/ldd.cpp										\
-  linux/memfd.cpp									\
   linux/ns.cpp										\
   linux/perf.cpp									\
   linux/systemd.cpp									\
@@ -1403,6 +1402,12 @@ MESOS_LINUX_FILES +=							\
   slave/containerizer/mesos/isolators/xfs/disk.hpp
 endif
 
+if ENABLE_LAUNCHER_SEALING
+MESOS_LINUX_FILES +=              \
+  linux/memfd.cpp             \
+  linux/memfd.hpp
+endif
+
 MESOS_LINUX_ROUTING_FILES =						\
   linux/routing/handle.cpp						\
   linux/routing/handle.hpp						\
@@ -2605,7 +2610,6 @@ mesos_tests_SOURCES +=						\
   tests/containerizer/cni_isolator_tests.cpp			\
   tests/containerizer/docker_volume_isolator_tests.cpp		\
   tests/containerizer/linux_filesystem_isolator_tests.cpp	\
-  tests/containerizer/linux_memfd_tests.cpp			\
   tests/containerizer/fs_tests.cpp				\
   tests/containerizer/memory_pressure_tests.cpp			\
   tests/containerizer/nested_mesos_containerizer_tests.cpp	\
@@ -2621,6 +2625,11 @@ mesos_tests_SOURCES +=						\
   tests/containerizer/volume_secret_isolator_tests.cpp
 endif
 
+if ENABLE_LAUNCHER_SEALING
+mesos_tests_SOURCES +=						\
+  tests/containerizer/linux_memfd_tests.cpp
+endif
+
 if ENABLE_LINUX_ROUTING
 mesos_tests_SOURCES +=						\
   tests/containerizer/routing_tests.cpp
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 89baa0a..2585b6c 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -218,7 +218,6 @@ if (LINUX)
     containerizer/fs_tests.cpp
     containerizer/linux_capabilities_isolator_tests.cpp
     containerizer/linux_filesystem_isolator_tests.cpp
-    containerizer/linux_memfd_tests.cpp
     containerizer/memory_pressure_tests.cpp
     containerizer/nested_mesos_containerizer_tests.cpp
     containerizer/ns_tests.cpp