Skip to content

Commit

Permalink
seccomp: re-add generation script
Browse files Browse the repository at this point in the history
The generate.go script used to fill the default seccomp profile file is
quite important as otherwise distributions will end up having outdated
seccomp filters even after a podman update.

This script comes from the Docker repo.

Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Jan 27, 2021
1 parent bf297c1 commit 2b92ef3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 74 deletions.
34 changes: 34 additions & 0 deletions pkg/seccomp/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// +build ignore

// Copyright 2013-2021 Docker, Inc.

package main

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"

"github.com/containers/common/pkg/seccomp"
)

// saves the default seccomp profile as a json file so people can use it as a
// base for their own custom profiles
func main() {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
f := filepath.Join(wd, "seccomp.json")

// write the default profile to the file
b, err := json.MarshalIndent(seccomp.DefaultProfile(), "", "\t")
if err != nil {
panic(err)
}

if err := ioutil.WriteFile(f, b, 0644); err != nil {
panic(err)
}
}
77 changes: 3 additions & 74 deletions pkg/seccomp/seccomp.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"ioprio_get",
"ioprio_set",
"ipc",
"keyctl",
"kill",
"lchown",
"lchown32",
Expand Down Expand Up @@ -574,19 +575,13 @@
{
"names": [
"bpf",
"clone",
"fanotify_init",
"lookup_dcookie",
"mount",
"name_to_handle_at",
"perf_event_open",
"quotactl",
"setdomainname",
"sethostname",
"setns",
"umount",
"umount2",
"unshare"
"setns"
],
"action": "SCMP_ACT_ALLOW",
"args": [],
Expand All @@ -598,71 +593,6 @@
},
"excludes": {}
},
{
"names": [
"clone"
],
"action": "SCMP_ACT_ALLOW",
"args": [
{
"index": 0,
"value": 2080505856,
"valueTwo": 0,
"op": "SCMP_CMP_MASKED_EQ"
}
],
"comment": "",
"includes": {},
"excludes": {
"caps": [
"CAP_SYS_ADMIN"
],
"arches": [
"s390",
"s390x"
]
}
},
{
"names": [
"clone"
],
"action": "SCMP_ACT_ALLOW",
"args": [
{
"index": 1,
"value": 2080505856,
"valueTwo": 0,
"op": "SCMP_CMP_MASKED_EQ"
}
],
"comment": "s390 parameter ordering for clone is different",
"includes": {
"arches": [
"s390",
"s390x"
]
},
"excludes": {
"caps": [
"CAP_SYS_ADMIN"
]
}
},
{
"names": [
"reboot"
],
"action": "SCMP_ACT_ALLOW",
"args": [],
"comment": "",
"includes": {
"caps": [
"CAP_SYS_BOOT"
]
},
"excludes": {}
},
{
"names": [
"chroot"
Expand Down Expand Up @@ -698,7 +628,6 @@
"names": [
"get_mempolicy",
"mbind",
"name_to_handle_at",
"set_mempolicy"
],
"action": "SCMP_ACT_ALLOW",
Expand Down Expand Up @@ -894,4 +823,4 @@
"excludes": {}
}
]
}
}

0 comments on commit 2b92ef3

Please sign in to comment.