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/01/28 07:52:34 UTC

[mesos] 03/11: Added Seccomp-related protobuf messages.

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 03e9e4edf92b8feaa27a6760cb121792218d36d7
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Sun Jan 27 23:51:56 2019 -0800

    Added Seccomp-related protobuf messages.
    
    See summary.
    
    Review: https://reviews.apache.org/r/68017/
---
 include/mesos/mesos.proto               |  14 +++++
 include/mesos/seccomp/seccomp.hpp       |  23 +++++++
 include/mesos/seccomp/seccomp.proto     | 104 ++++++++++++++++++++++++++++++++
 include/mesos/slave/containerizer.proto |   6 ++
 include/mesos/v1/mesos.proto            |  14 +++++
 src/CMakeLists.txt                      |   1 +
 src/Makefile.am                         |  13 ++++
 7 files changed, 175 insertions(+)

diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 2ef6ba3..3477b7d 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -3147,6 +3147,17 @@ message CapabilityInfo {
 
 
 /**
+ * Encapsulation for Seccomp configuration, which is Linux specific.
+ */
+message SeccompInfo {
+  // A filename of the Seccomp profile. This should be a path
+  // relative to the directory containing Seccomp profiles,
+  // which is specified on the agent via the `--seccomp_config_dir` flag.
+  optional string profile_name = 1;
+}
+
+
+/**
  * Encapsulation for Linux specific configuration.
  * E.g, capabilities, limits etc.
  */
@@ -3169,6 +3180,9 @@ message LinuxInfo {
   // parent container. This field will be ignored if 'namespaces/pid'
   // isolator is not enabled.
   optional bool share_pid_namespace = 4;
+
+  // Represents Seccomp configuration, which is used for syscall filtering.
+  optional SeccompInfo seccomp = 5;
 }
 
 
diff --git a/include/mesos/seccomp/seccomp.hpp b/include/mesos/seccomp/seccomp.hpp
new file mode 100644
index 0000000..45765e2
--- /dev/null
+++ b/include/mesos/seccomp/seccomp.hpp
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __SECCOMP_PROTO_HPP__
+#define __SECCOMP_PROTO_HPP__
+
+// ONLY USEFUL AFTER RUNNING PROTOC.
+#include <mesos/seccomp/seccomp.pb.h>
+
+#endif // __SECCOMP_PROTO_HPP__
diff --git a/include/mesos/seccomp/seccomp.proto b/include/mesos/seccomp/seccomp.proto
new file mode 100644
index 0000000..48e35bc
--- /dev/null
+++ b/include/mesos/seccomp/seccomp.proto
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto2";
+
+import "mesos/mesos.proto";
+
+package mesos.seccomp;
+
+/**
+ * Encapsulation of Linux seccomp filter
+ * Reference: https://github.com/seccomp/libseccomp/blob/master/include/seccomp.h.in // NOLINT
+ */
+message ContainerSeccompProfile {
+  enum Architecture {
+    UNKNOWN = 0;
+    ARCH_X86 = 1;
+    ARCH_X86_64 = 2;
+    ARCH_X32 = 3;
+    ARCH_ARM = 4;
+    ARCH_AARCH64 = 5;
+    ARCH_MIPS = 6;
+    ARCH_MIPSEL = 7;
+    ARCH_MIPS64 = 8;
+    ARCH_MIPSEL64 = 9;
+    ARCH_MIPS64N32 = 10;
+    ARCH_MIPSEL64N32 = 11;
+    ARCH_PPC = 12;
+    ARCH_PPC64 = 13;
+    ARCH_PPC64LE = 14;
+    ARCH_S390 = 15;
+    ARCH_S390X = 16;
+  }
+
+  message Syscall {
+    enum Action {
+      UNKNOWN = 0;
+      ACT_KILL = 1;
+      ACT_TRAP = 2;
+      ACT_ERRNO = 3;
+      ACT_TRACE = 4;
+      ACT_ALLOW = 5;
+    }
+
+    message Arg {
+      enum Operator {
+        UNKNOWN = 0;
+        CMP_NE = 1;        // not equal
+        CMP_LT = 2;        // less than
+        CMP_LE = 3;        // less than or equal
+        CMP_EQ = 4;        // equal
+        CMP_GE = 5;        // greater than or equal
+        CMP_GT = 6;        // greater than
+        CMP_MASKED_EQ = 7; // masked equality
+      }
+
+      // The number of the argument we are checking, starting at 0.
+      required uint32 index = 1;
+
+      // The comparison operator, e.g. CMP_*.
+      required Operator op = 2;
+
+      // The first comparison value. The rule will match if argument
+      // $syscall_arg[index] is $COMPARE_OP the provided comparison value.
+      required uint64 value = 3;
+
+      // Some comparison operators accept two values. Masked equals,
+      // for example, will mask $syscall_arg[index] with the second value
+      // provided (via bitwise AND) and then compare against the first
+      // value provided.
+      required uint64 value_two = 4;
+    }
+
+    // Encapsulation of filtering rules of the given `Syscall` rule.
+    // Filtering means that we either include or exclude the given
+    // `Syscall` rule by matching rules provided in the `Filter`.
+    message Filter {
+      repeated CapabilityInfo.Capability capabilities = 1;
+    }
+
+    repeated string names = 1;
+    required Action action = 2;
+    repeated Arg args = 3;
+    optional Filter includes = 4;
+    optional Filter excludes = 5;
+  }
+
+  required Syscall.Action default_action = 1;
+  repeated Architecture architectures = 2;
+  repeated Syscall syscalls = 3;
+}
\ No newline at end of file
diff --git a/include/mesos/slave/containerizer.proto b/include/mesos/slave/containerizer.proto
index 5b4dcdd..7d16463 100644
--- a/include/mesos/slave/containerizer.proto
+++ b/include/mesos/slave/containerizer.proto
@@ -24,6 +24,8 @@ import "mesos/appc/spec.proto";
 
 import "mesos/docker/v1.proto";
 
+import "mesos/seccomp/seccomp.proto";
+
 /**
  * Some containers are launched in conjunction with a specific
  * `ContainerClass`. These classes allow an isolator to customize
@@ -238,6 +240,10 @@ message ContainerLaunchInfo {
   // this list will be mounted in order.
   repeated ContainerMountInfo mounts = 17;
 
+  // (Linux only) The Seccomp profile for the container.
+  // The profile is used to configure syscall filtering via `libseccomp`.
+  optional seccomp.ContainerSeccompProfile seccomp_profile = 18;
+
   // (Linux only) The capabilities requested for the container.
   // The capabilities are set while launching the container.
   optional CapabilityInfo effective_capabilities = 7;
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 1a701da..692940b 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -3140,6 +3140,17 @@ message CapabilityInfo {
 
 
 /**
+ * Encapsulation for Seccomp configuration, which is Linux specific.
+ */
+message SeccompInfo {
+  // A filename of the Seccomp profile. This should be a path
+  // relative to the directory containing Seccomp profiles,
+  // which is specified on the agent via the `--seccomp_config_dir` flag.
+  optional string profile_name = 1;
+}
+
+
+/**
  * Encapsulation for Linux specific configuration.
  * E.g, capabilities, limits etc.
  */
@@ -3162,6 +3173,9 @@ message LinuxInfo {
   // parent container. This field will be ignored if 'namespaces/pid'
   // isolator is not enabled.
   optional bool share_pid_namespace = 4;
+
+  // Represents Seccomp configuration, which is used for syscall filtering.
+  optional SeccompInfo seccomp = 5;
 }
 
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1748f8f..91bcdad 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -52,6 +52,7 @@ PROTOC_GENERATE(TARGET mesos/module/module)
 PROTOC_GENERATE(TARGET mesos/oci/spec)
 PROTOC_GENERATE(TARGET mesos/quota/quota)
 PROTOC_GENERATE(TARGET mesos/resource_provider/resource_provider)
+PROTOC_GENERATE(TARGET mesos/seccomp/seccomp)
 PROTOC_GENERATE(TARGET mesos/slave/containerizer)
 PROTOC_GENERATE(TARGET mesos/slave/oversubscription)
 PROTOC_GENERATE(TARGET mesos/state/state)
diff --git a/src/Makefile.am b/src/Makefile.am
index 929d2d0..fa9bbae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -309,6 +309,7 @@ OCI_SPEC_PROTO = $(top_srcdir)/include/mesos/oci/spec.proto
 QUOTA_PROTO = $(top_srcdir)/include/mesos/quota/quota.proto
 RESOURCE_PROVIDER_PROTO = $(top_srcdir)/include/mesos/resource_provider/resource_provider.proto
 SCHEDULER_PROTO = $(top_srcdir)/include/mesos/scheduler/scheduler.proto
+SECCOMP_PROTO = $(top_srcdir)/include/mesos/seccomp/seccomp.proto
 STATE_PROTO = $(top_srcdir)/include/mesos/state/state.proto
 OVERSUBSCRIPTION_PROTO = $(top_srcdir)/include/mesos/slave/oversubscription.proto
 URI_PROTO = $(top_srcdir)/include/mesos/uri/uri.proto
@@ -366,6 +367,8 @@ CXX_PROTOS =								\
   ../include/mesos/resource_provider/resource_provider.pb.h		\
   ../include/mesos/scheduler/scheduler.pb.cc				\
   ../include/mesos/scheduler/scheduler.pb.h				\
+  ../include/mesos/seccomp/seccomp.pb.cc				\
+  ../include/mesos/seccomp/seccomp.pb.h					\
   ../include/mesos/slave/containerizer.pb.cc				\
   ../include/mesos/slave/containerizer.pb.h				\
   ../include/mesos/slave/oversubscription.pb.cc				\
@@ -825,6 +828,15 @@ scheduler_HEADERS =							\
 nodist_scheduler_HEADERS =						\
   ../include/mesos/scheduler/scheduler.pb.h
 
+seccompdir = $(pkgincludedir)/seccomp
+
+seccomp_HEADERS =							\
+  $(top_srcdir)/include/mesos/seccomp/seccomp.hpp			\
+  $(top_srcdir)/include/mesos/seccomp/seccomp.proto
+
+nodist_seccomp_HEADERS =						\
+  ../include/mesos/seccomp/seccomp.pb.h
+
 agentdir = $(pkgincludedir)/agent
 
 agent_HEADERS =								\
@@ -1628,6 +1640,7 @@ libmesos_la_SOURCES =							\
   $(QUOTA_PROTO)							\
   $(RESOURCE_PROVIDER_PROTO)						\
   $(SCHEDULER_PROTO)							\
+  $(SECCOMP_PROTO)							\
   $(STATE_PROTO)							\
   $(URI_PROTO)								\
   $(V1_AGENT_PROTO)							\