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/03/05 23:01:23 UTC

[mesos] branch master updated (5382cc0 -> 549068a)

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

gilbert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from 5382cc0  Removed an outdated comment in SLRP.
     new c6f3334  Added `unconfined` flag to `SeccompInfo` message.
     new 3681c43  Added `LinuxSeccompIsolatorTest.LaunchWithSeccompDisabled` test.
     new 549068a  Added logging for `linux/seccomp` isolator.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/isolators/linux-seccomp.md                    |  4 +-
 include/mesos/mesos.proto                          |  7 ++
 include/mesos/v1/mesos.proto                       |  7 ++
 .../mesos/isolators/linux/seccomp.cpp              | 24 ++++++-
 .../containerizer/linux_seccomp_isolator_tests.cpp | 79 ++++++++++++++++++++++
 5 files changed, 118 insertions(+), 3 deletions(-)


[mesos] 01/03: Added `unconfined` flag to `SeccompInfo` message.

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c6f3334c43e95f6486942256f77ed2aa926c4d1b
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Tue Mar 5 15:00:53 2019 -0800

    Added `unconfined` flag to `SeccompInfo` message.
    
    This patch introduces `unconfined` flag that can be used by a framework
    to explicitly disable Seccomp filtering for a particular container.
    
    Review: https://reviews.apache.org/r/70108/
---
 docs/isolators/linux-seccomp.md                           |  4 +++-
 include/mesos/mesos.proto                                 |  7 +++++++
 include/mesos/v1/mesos.proto                              |  7 +++++++
 src/slave/containerizer/mesos/isolators/linux/seccomp.cpp | 12 ++++++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/docs/isolators/linux-seccomp.md b/docs/isolators/linux-seccomp.md
index 7594526..dc027c0 100644
--- a/docs/isolators/linux-seccomp.md
+++ b/docs/isolators/linux-seccomp.md
@@ -53,4 +53,6 @@ sudo mesos-agent --master=<master ip> --ip=<agent ip>
 
 In order for a Mesos task to override the agent's default Seccomp profile,
 it should declare the required profile in the `LinuxInfo` field of its
-`ContainerInfo`.
+`ContainerInfo`. E.g., if the agent is launched with the default Seccomp
+profile enabled, a framework can disable Seccomp for a particular task by
+setting an `unconfined` field in the corresponding `SeccompInfo`.
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 48f30b3..d373a1d 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -3214,6 +3214,13 @@ message SeccompInfo {
   // relative to the directory containing Seccomp profiles,
   // which is specified on the agent via the `--seccomp_config_dir` flag.
   optional string profile_name = 1;
+
+  // If set to `true`, Seccomp is not applied to the container.
+  // If not set or set to `false`, the container is launched with
+  // the profile specified in the `profile_name` field.
+  //
+  // NOTE: `profile_name` should not be specified if `unconfined` set to `true`.
+  optional bool unconfined = 2;
 }
 
 
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index e07dd9e..e53596f 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -3207,6 +3207,13 @@ message SeccompInfo {
   // relative to the directory containing Seccomp profiles,
   // which is specified on the agent via the `--seccomp_config_dir` flag.
   optional string profile_name = 1;
+
+  // If set to `true`, Seccomp is not applied to the container.
+  // If not set or set to `false`, the container is launched with
+  // the profile specified in the `profile_name` field.
+  //
+  // NOTE: `profile_name` should not be specified if `unconfined` set to `true`.
+  optional bool unconfined = 2;
 }
 
 
diff --git a/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp b/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp
index 1c94e12..f0c58c1 100644
--- a/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp
+++ b/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp
@@ -93,6 +93,16 @@ Future<Option<ContainerLaunchInfo>> LinuxSeccompIsolatorProcess::prepare(
     const auto& seccomp =
       containerConfig.container_info().linux_info().seccomp();
 
+    const bool unconfined =
+      seccomp.has_unconfined() ? seccomp.unconfined() : false;
+
+    // Validate Seccomp configuration.
+    if (unconfined && seccomp.has_profile_name()) {
+      return Failure(
+          "Invalid Seccomp configuration: 'profile_name' given even "
+          "though 'unconfined' Seccomp setting is enabled");
+    }
+
     if (seccomp.has_profile_name()) {
       const auto path =
         path::join(flags.seccomp_config_dir.get(), seccomp.profile_name());
@@ -105,6 +115,8 @@ Future<Option<ContainerLaunchInfo>> LinuxSeccompIsolatorProcess::prepare(
       }
 
       profile = customProfile.get();
+    } else if (unconfined) {
+      return None();
     } else {
       return Failure("Missing Seccomp profile name");
     }


[mesos] 02/03: Added `LinuxSeccompIsolatorTest.LaunchWithSeccompDisabled` test.

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3681c43fc2543ef9076289840b1f0c940f3341e9
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Tue Mar 5 15:00:55 2019 -0800

    Added `LinuxSeccompIsolatorTest.LaunchWithSeccompDisabled` test.
    
    This test verifies that Seccomp filtering can be disabled via
    `unconfined` flag in `SeccompInfo` message. We create a Mesos
    containerizer with a default Seccomp profile that prohibits
    `uname` syscall. Then, `uname` command is launched with `unconfined`
    flag set, so it's expected that the Seccomp filter does not affect
    this command.
    
    Review: https://reviews.apache.org/r/70109/
---
 .../containerizer/linux_seccomp_isolator_tests.cpp | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/src/tests/containerizer/linux_seccomp_isolator_tests.cpp b/src/tests/containerizer/linux_seccomp_isolator_tests.cpp
index 1c4c3b1..b737ff7 100644
--- a/src/tests/containerizer/linux_seccomp_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_seccomp_isolator_tests.cpp
@@ -1025,6 +1025,85 @@ TEST_F(LinuxSeccompIsolatorTest, ROOT_SECCOMP_LaunchWithUnameDisabled)
 }
 
 
+// This test verifies that we can disable Seccomp filtering for a particular
+// task.
+TEST_F(LinuxSeccompIsolatorTest, ROOT_SECCOMP_LaunchWithSeccompDisabled)
+{
+  const string config =
+    R"~(
+    {
+      "defaultAction": "SCMP_ACT_ALLOW",
+      "archMap": [
+        {
+          "architecture": "SCMP_ARCH_X86_64",
+          "subArchitectures": [
+            "SCMP_ARCH_X86",
+            "SCMP_ARCH_X32"
+          ]
+        }
+      ],
+      "syscalls": [
+        {
+          "names": ["uname"],
+          "action": "SCMP_ACT_ERRNO",
+          "args": [],
+          "includes": {},
+          "excludes": {}
+        }
+      ]
+    })~";
+
+  slave::Flags flags = CreateSlaveFlags();
+  flags.seccomp_profile_name = createProfile(config);
+
+  Fetcher fetcher(flags);
+
+  Try<MesosContainerizer*> create =
+    MesosContainerizer::create(flags, false, &fetcher);
+
+  ASSERT_SOME(create);
+
+  Owned<MesosContainerizer> containerizer(create.get());
+
+  SlaveState state;
+  state.id = SlaveID();
+
+  AWAIT_READY(containerizer->recover(state));
+
+  ContainerID containerId;
+  containerId.set_value(id::UUID::random().toString());
+
+  Try<string> directory = environment->mkdtemp();
+  ASSERT_SOME(directory);
+
+  auto containerConfig =  createContainerConfig(
+      None(),
+      createExecutorInfo("executor", "uname", "cpus:1"),
+      directory.get());
+
+  ContainerInfo* container = containerConfig.mutable_container_info();
+  container->set_type(ContainerInfo::MESOS);
+
+  SeccompInfo* seccomp = container->mutable_linux_info()->mutable_seccomp();
+  seccomp->set_unconfined(true);
+
+  Future<Containerizer::LaunchResult> launch = containerizer->launch(
+      containerId,
+      containerConfig,
+      map<string, string>(),
+      None());
+
+  AWAIT_ASSERT_EQ(Containerizer::LaunchResult::SUCCESS, launch);
+
+  Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
+
+  AWAIT_READY(wait);
+  ASSERT_SOME(wait.get());
+  ASSERT_TRUE(wait.get()->has_status());
+  EXPECT_WEXITSTATUS_EQ(0, wait.get()->status());
+}
+
+
 // This test verifies that we can launch a task container with overridden
 // Seccomp profile.
 TEST_F(LinuxSeccompIsolatorTest, ROOT_SECCOMP_LaunchWithOverriddenProfile)


[mesos] 03/03: Added logging for `linux/seccomp` isolator.

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 549068ae3666794cce9b3f19ffe4629a0acaaddd
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Tue Mar 5 15:00:56 2019 -0800

    Added logging for `linux/seccomp` isolator.
    
    Review: https://reviews.apache.org/r/70114/
---
 src/slave/containerizer/mesos/isolators/linux/seccomp.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp b/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp
index f0c58c1..5624c24 100644
--- a/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp
+++ b/src/slave/containerizer/mesos/isolators/linux/seccomp.cpp
@@ -86,6 +86,9 @@ Future<Option<ContainerLaunchInfo>> LinuxSeccompIsolatorProcess::prepare(
 {
   Option<ContainerSeccompProfile> profile = defaultProfile;
 
+  std::string profileName =
+    flags.seccomp_profile_name.isSome() ? flags.seccomp_profile_name.get() : "";
+
   // Framework can override default Seccomp profile for a particular container.
   if (containerConfig.has_container_info() &&
       containerConfig.container_info().has_linux_info() &&
@@ -104,8 +107,8 @@ Future<Option<ContainerLaunchInfo>> LinuxSeccompIsolatorProcess::prepare(
     }
 
     if (seccomp.has_profile_name()) {
-      const auto path =
-        path::join(flags.seccomp_config_dir.get(), seccomp.profile_name());
+      profileName = seccomp.profile_name();
+      const auto path = path::join(flags.seccomp_config_dir.get(), profileName);
 
       Try<ContainerSeccompProfile> customProfile =
         mesos::internal::seccomp::parseProfile(path);
@@ -116,6 +119,8 @@ Future<Option<ContainerLaunchInfo>> LinuxSeccompIsolatorProcess::prepare(
 
       profile = customProfile.get();
     } else if (unconfined) {
+      LOG(INFO) << "Seccomp is not applied to container " << containerId;
+
       return None();
     } else {
       return Failure("Missing Seccomp profile name");
@@ -129,6 +134,9 @@ Future<Option<ContainerLaunchInfo>> LinuxSeccompIsolatorProcess::prepare(
   ContainerLaunchInfo launchInfo;
   launchInfo.mutable_seccomp_profile()->CopyFrom(profile.get());
 
+  LOG(INFO) << "Using Seccomp profile '" << profileName
+            << "' for container " << containerId;
+
   return launchInfo;
 }