aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar AdamKorcz <44787359+AdamKorcz@users.noreply.github.com>2021-03-05 16:17:35 +0000
committerGravatar GitHub <noreply@github.com>2021-03-05 08:17:35 -0800
commitd18cc7df58b9b1dae3bceafb9c0a6a3e1edd68e5 (patch)
tree93d4efa8009f9156c9bf3d69adbf3efc300d66fb
parentff77b152807e588789630b6cc39a631780be7028 (diff)
[runc] Initial integration (#5287)
* [teleport] Initial integration * Minor update to run tests again * Remove debugging things * Removed an unfinished file * Small nit * Added maintainers * Update Dockerfile * Update build.sh * Update project.yaml * Updated licenses Co-authored-by: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>
-rw-r--r--projects/runc/Dockerfile24
-rw-r--r--projects/runc/build.sh25
-rw-r--r--projects/runc/configs_fuzzer.go35
-rw-r--r--projects/runc/id_map_fuzzer.go28
-rw-r--r--projects/runc/project.yaml16
-rw-r--r--projects/runc/user_fuzzer.go58
6 files changed, 186 insertions, 0 deletions
diff --git a/projects/runc/Dockerfile b/projects/runc/Dockerfile
new file mode 100644
index 00000000..63e3017f
--- /dev/null
+++ b/projects/runc/Dockerfile
@@ -0,0 +1,24 @@
+# Copyright 2021 Google LLC
+#
+# Licensed 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.
+#
+################################################################################
+
+FROM gcr.io/oss-fuzz-base/base-builder
+RUN git clone --depth 1 https://github.com/opencontainers/runc
+COPY build.sh \
+ id_map_fuzzer.go \
+ user_fuzzer.go \
+ configs_fuzzer.go \
+ $SRC/
+WORKDIR $SRC/runc
diff --git a/projects/runc/build.sh b/projects/runc/build.sh
new file mode 100644
index 00000000..4c30ab5a
--- /dev/null
+++ b/projects/runc/build.sh
@@ -0,0 +1,25 @@
+#!/bin/bash -eu
+# Copyright 2021 Google LLC
+#
+# Licensed 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.
+#
+################################################################################
+
+mv $SRC/id_map_fuzzer.go $SRC/runc/libcontainer/system/
+compile_go_fuzzer ./libcontainer/system Fuzz id_map_fuzzer linux
+
+mv $SRC/user_fuzzer.go $SRC/runc/libcontainer/user
+compile_go_fuzzer ./libcontainer/user Fuzz user_fuzzer
+
+mv $SRC/configs_fuzzer.go $SRC/runc/libcontainer/configs
+compile_go_fuzzer ./libcontainer/configs Fuzz configs_fuzzer
diff --git a/projects/runc/configs_fuzzer.go b/projects/runc/configs_fuzzer.go
new file mode 100644
index 00000000..d482ba0f
--- /dev/null
+++ b/projects/runc/configs_fuzzer.go
@@ -0,0 +1,35 @@
+// Copyright 2021 Google LLC
+//
+// Licensed 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.
+//
+
+package configs
+
+import(
+ "fmt"
+)
+
+
+func Fuzz(data []byte) int {
+ hookNameList := []string {"prestart",
+ "createRuntime",
+ "createContainer",
+ "startContainer",
+ "poststart"}
+
+ for _, hookName := range hookNameList {
+ hooks := Hooks{}
+ _ = hooks.UnmarshalJSON([]byte(fmt.Sprintf(`{"%s" :[%s]}`, hookName, data)))
+ }
+ return 1
+}
diff --git a/projects/runc/id_map_fuzzer.go b/projects/runc/id_map_fuzzer.go
new file mode 100644
index 00000000..4d842a4c
--- /dev/null
+++ b/projects/runc/id_map_fuzzer.go
@@ -0,0 +1,28 @@
+// Copyright 2021 Google LLC
+//
+// Licensed 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.
+//
+
+package system
+
+import (
+ "strings"
+ "github.com/opencontainers/runc/libcontainer/user"
+)
+
+
+func Fuzz(data []byte) int {
+ uidmap, _ := user.ParseIDMap(strings.NewReader(string(data)))
+ _ = UIDMapInUserNS(uidmap)
+ return 1
+}
diff --git a/projects/runc/project.yaml b/projects/runc/project.yaml
new file mode 100644
index 00000000..fc387c82
--- /dev/null
+++ b/projects/runc/project.yaml
@@ -0,0 +1,16 @@
+homepage: "https://github.com/opencontainers/runc"
+main_repo: "https://github.com/opencontainers/runc"
+primary_contact: "cyphar@cyphar.com"
+auto_ccs:
+ - "adam@adalogics.com"
+ - "michael@docker.com"
+ - "mpatel@redhat.com"
+ - "dqminh89@gmail.com"
+ - "h.huangqiang@huawei.com"
+ - "akihiro.suda.cz@hco.ntt.co.jp"
+ - "kolyshkin@gmail.com"
+language: go
+fuzzing_engines:
+ - libfuzzer
+sanitizers:
+ - address
diff --git a/projects/runc/user_fuzzer.go b/projects/runc/user_fuzzer.go
new file mode 100644
index 00000000..b3a2ca71
--- /dev/null
+++ b/projects/runc/user_fuzzer.go
@@ -0,0 +1,58 @@
+// Copyright 2021 Google LLC
+//
+// Licensed 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.
+//
+
+package user
+
+import (
+ "strings"
+ "io"
+)
+
+
+func IsDivisbleBy(n int, divisibleby int) bool {
+ return (n % divisibleby) == 0
+}
+
+func Fuzz(data []byte) int {
+ if len(data)==0 {
+ return -1
+ }
+ divisible := IsDivisbleBy(len(data), 5)
+ if divisible==false {
+ return -1
+ }
+
+ var divided [][]byte
+
+ chunkSize := len(data)/5
+
+ for i := 0; i < len(data); i += chunkSize {
+ end := i + chunkSize
+
+ divided = append(divided, data[i:end])
+ }
+
+ _, _ = ParsePasswdFilter(strings.NewReader(string(divided[0])), nil)
+
+ var passwd, group io.Reader
+
+ group = strings.NewReader(string(divided[1]))
+ _, _ = GetAdditionalGroups([]string{string(divided[2])}, group)
+
+
+ passwd = strings.NewReader(string(divided[3]))
+ _, _ = GetExecUser(string(divided[4]), nil, passwd, group)
+ return 1
+}