Browse code

profiles/apparmor, seccomp: migrate to separate module

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/07/23 00:13:44
Showing 34 changed files
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"fmt"
7 7
 
8 8
 	"github.com/containerd/containerd/v2/pkg/apparmor"
9
-	aaprofile "github.com/docker/docker/profiles/apparmor"
9
+	aaprofile "github.com/moby/profiles/apparmor"
10 10
 )
11 11
 
12 12
 // Define constants for native driver
... ...
@@ -9,7 +9,7 @@ import (
9 9
 	"github.com/containerd/log"
10 10
 	dconfig "github.com/docker/docker/daemon/config"
11 11
 	"github.com/docker/docker/daemon/container"
12
-	"github.com/docker/docker/profiles/seccomp"
12
+	"github.com/moby/profiles/seccomp"
13 13
 	"github.com/opencontainers/runtime-spec/specs-go"
14 14
 )
15 15
 
... ...
@@ -8,8 +8,8 @@ import (
8 8
 	"github.com/docker/docker/daemon/container"
9 9
 	"github.com/docker/docker/oci"
10 10
 	"github.com/docker/docker/pkg/sysinfo"
11
-	"github.com/docker/docker/profiles/seccomp"
12 11
 	containertypes "github.com/moby/moby/api/types/container"
12
+	"github.com/moby/profiles/seccomp"
13 13
 	"github.com/opencontainers/runtime-spec/specs-go"
14 14
 	"gotest.tools/v3/assert"
15 15
 )
... ...
@@ -22,6 +22,7 @@ import (
22 22
 	"github.com/docker/docker/pkg/sysinfo"
23 23
 	"github.com/docker/docker/testutil"
24 24
 	"github.com/moby/moby/client"
25
+	"github.com/moby/profiles/seccomp"
25 26
 	"github.com/moby/sys/mount"
26 27
 	"gotest.tools/v3/assert"
27 28
 	is "gotest.tools/v3/assert/cmp"
... ...
@@ -1319,7 +1320,16 @@ func (s *DockerCLIRunSuite) TestRunApparmorProcDirectory(c *testing.T) {
1319 1319
 func (s *DockerCLIRunSuite) TestRunSeccompWithDefaultProfile(c *testing.T) {
1320 1320
 	testRequires(c, testEnv.IsLocalDaemon, seccompEnabled)
1321 1321
 
1322
-	out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp=../profiles/seccomp/default.json", "debian:bookworm-slim", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
1322
+	// write the default profile to a file
1323
+	b, err := json.MarshalIndent(seccomp.DefaultProfile(), "", "\t")
1324
+	assert.NilError(c, err)
1325
+
1326
+	tmpDir := c.TempDir()
1327
+	fileName := filepath.Join(tmpDir, "default.json")
1328
+	err = os.WriteFile(fileName, b, 0o644)
1329
+	assert.NilError(c, err)
1330
+
1331
+	out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp="+fileName, "debian:bookworm-slim", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
1323 1332
 	assert.ErrorContains(c, err, "", out)
1324 1333
 	assert.Equal(c, strings.TrimSpace(out), "unshare: unshare failed: Operation not permitted")
1325 1334
 }
... ...
@@ -7,7 +7,7 @@ import (
7 7
 	"os"
8 8
 	"testing"
9 9
 
10
-	"github.com/docker/docker/profiles/seccomp"
10
+	"github.com/moby/profiles/seccomp"
11 11
 )
12 12
 
13 13
 func TestSeccompLoadProfile(t *testing.T) {
14 14
deleted file mode 100644
... ...
@@ -1,132 +0,0 @@
1
-//go:build linux
2
-
3
-package apparmor
4
-
5
-import (
6
-	"bufio"
7
-	"fmt"
8
-	"io"
9
-	"os"
10
-	"os/exec"
11
-	"path"
12
-	"strings"
13
-	"text/template"
14
-)
15
-
16
-// profileDirectory is the file store for apparmor profiles and macros.
17
-const profileDirectory = "/etc/apparmor.d"
18
-
19
-// profileData holds information about the given profile for generation.
20
-type profileData struct {
21
-	// Name is profile name.
22
-	Name string
23
-	// DaemonProfile is the profile name of our daemon.
24
-	DaemonProfile string
25
-	// Imports defines the apparmor functions to import, before defining the profile.
26
-	Imports []string
27
-	// InnerImports defines the apparmor functions to import in the profile.
28
-	InnerImports []string
29
-}
30
-
31
-// generateDefault creates an apparmor profile from ProfileData.
32
-func (p *profileData) generateDefault(out io.Writer) error {
33
-	compiled, err := template.New("apparmor_profile").Parse(baseTemplate)
34
-	if err != nil {
35
-		return err
36
-	}
37
-
38
-	if macroExists("tunables/global") {
39
-		p.Imports = append(p.Imports, "#include <tunables/global>")
40
-	} else {
41
-		p.Imports = append(p.Imports, "@{PROC}=/proc/")
42
-	}
43
-
44
-	if macroExists("abstractions/base") {
45
-		p.InnerImports = append(p.InnerImports, "#include <abstractions/base>")
46
-	}
47
-
48
-	return compiled.Execute(out, p)
49
-}
50
-
51
-// macroExists checks if the passed macro exists.
52
-func macroExists(m string) bool {
53
-	_, err := os.Stat(path.Join(profileDirectory, m))
54
-	return err == nil
55
-}
56
-
57
-// InstallDefault generates a default profile in a temp directory determined by
58
-// os.TempDir(), then loads the profile into the kernel using 'apparmor_parser'.
59
-func InstallDefault(name string) error {
60
-	// Figure out the daemon profile.
61
-	daemonProfile := "unconfined"
62
-	if currentProfile, err := os.ReadFile("/proc/self/attr/current"); err == nil {
63
-		// Normally profiles are suffixed by " (enforcing)" or similar. AppArmor
64
-		// profiles cannot contain spaces so this doesn't restrict daemon profile
65
-		// names.
66
-		if profile, _, _ := strings.Cut(string(currentProfile), " "); profile != "" {
67
-			daemonProfile = profile
68
-		}
69
-	}
70
-
71
-	// Install to a temporary directory.
72
-	tmpFile, err := os.CreateTemp("", name)
73
-	if err != nil {
74
-		return err
75
-	}
76
-
77
-	defer func() {
78
-		_ = tmpFile.Close()
79
-		_ = os.Remove(tmpFile.Name())
80
-	}()
81
-
82
-	p := profileData{
83
-		Name:          name,
84
-		DaemonProfile: daemonProfile,
85
-	}
86
-	if err := p.generateDefault(tmpFile); err != nil {
87
-		return err
88
-	}
89
-
90
-	return loadProfile(tmpFile.Name())
91
-}
92
-
93
-// IsLoaded checks if a profile with the given name has been loaded into the
94
-// kernel.
95
-func IsLoaded(name string) (bool, error) {
96
-	return isLoaded(name, "/sys/kernel/security/apparmor/profiles")
97
-}
98
-
99
-func isLoaded(name string, fileName string) (bool, error) {
100
-	file, err := os.Open(fileName)
101
-	if err != nil {
102
-		return false, err
103
-	}
104
-	defer file.Close()
105
-
106
-	scanner := bufio.NewScanner(file)
107
-	for scanner.Scan() {
108
-		if prefix, _, ok := strings.Cut(scanner.Text(), " "); ok && prefix == name {
109
-			return true, nil
110
-		}
111
-	}
112
-
113
-	if err := scanner.Err(); err != nil {
114
-		return false, err
115
-	}
116
-
117
-	return false, nil
118
-}
119
-
120
-// loadProfile runs `apparmor_parser -Kr` on a specified apparmor profile to
121
-// replace the profile. The `-K` is necessary to make sure that apparmor_parser
122
-// doesn't try to write to a read-only filesystem.
123
-func loadProfile(profilePath string) error {
124
-	c := exec.Command("apparmor_parser", "-Kr", profilePath)
125
-	c.Dir = ""
126
-
127
-	if output, err := c.CombinedOutput(); err != nil {
128
-		return fmt.Errorf("running '%s' failed with output: %s\nerror: %v", c, output, err)
129
-	}
130
-
131
-	return nil
132
-}
133 1
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+//go:build linux
1
+
2
+package apparmor
3
+
4
+import "github.com/moby/profiles/apparmor"
5
+
6
+// InstallDefault generates a default profile in a temp directory determined by
7
+// os.TempDir(), then loads the profile into the kernel using 'apparmor_parser'.
8
+//
9
+// Deprecated: use [apparmor.InstallDefault].
10
+func InstallDefault(name string) error {
11
+	return apparmor.InstallDefault(name)
12
+}
13
+
14
+// IsLoaded checks if a profile with the given name has been loaded into the
15
+// kernel.
16
+//
17
+// Deprecated: use [apparmor.IsLoaded].
18
+func IsLoaded(name string) (bool, error) {
19
+	return apparmor.IsLoaded(name)
20
+}
0 21
deleted file mode 100644
... ...
@@ -1,197 +0,0 @@
1
-package apparmor
2
-
3
-import (
4
-	"errors"
5
-	"os"
6
-	"path"
7
-	"path/filepath"
8
-	"strings"
9
-	"testing"
10
-)
11
-
12
-// testAppArmorProfiles fixture "/sys/kernel/security/apparmor/profiles"
13
-// from an Ubuntu 24.10 host.
14
-const testAppArmorProfiles = `wpcom (unconfined)
15
-wike (unconfined)
16
-vpnns (unconfined)
17
-vivaldi-bin (unconfined)
18
-virtiofsd (unconfined)
19
-vdens (unconfined)
20
-uwsgi-core (unconfined)
21
-rsyslogd (enforce)
22
-/usr/lib/snapd/snap-confine (enforce)
23
-/usr/lib/snapd/snap-confine//mount-namespace-capture-helper (enforce)
24
-tcpdump (enforce)
25
-man_groff (enforce)
26
-man_filter (enforce)
27
-/usr/bin/man (enforce)
28
-userbindmount (unconfined)
29
-unprivileged_userns (enforce)
30
-unix-chkpwd (enforce)
31
-ubuntu_pro_esm_cache_systemd_detect_virt (enforce)
32
-ubuntu_pro_esm_cache_systemctl (enforce)
33
-ubuntu_pro_esm_cache (enforce)
34
-ubuntu_pro_esm_cache//ubuntu_distro_info (enforce)
35
-ubuntu_pro_esm_cache//ps (enforce)
36
-ubuntu_pro_esm_cache//dpkg (enforce)
37
-ubuntu_pro_esm_cache//cloud_id (enforce)
38
-ubuntu_pro_esm_cache//apt_methods_gpgv (enforce)
39
-ubuntu_pro_esm_cache//apt_methods (enforce)
40
-ubuntu_pro_apt_news (enforce)
41
-tuxedo-control-center (unconfined)
42
-tup (unconfined)
43
-trinity (unconfined)
44
-transmission-qt (complain)
45
-transmission-gtk (complain)
46
-transmission-daemon (complain)
47
-transmission-cli (complain)
48
-toybox (unconfined)
49
-thunderbird (unconfined)
50
-systemd-coredump (unconfined)
51
-surfshark (unconfined)
52
-stress-ng (unconfined)
53
-steam (unconfined)
54
-slirp4netns (unconfined)
55
-slack (unconfined)
56
-signal-desktop (unconfined)
57
-scide (unconfined)
58
-sbuild-upgrade (unconfined)
59
-sbuild-update (unconfined)
60
-sbuild-unhold (unconfined)
61
-sbuild-shell (unconfined)
62
-sbuild-hold (unconfined)
63
-sbuild-distupgrade (unconfined)
64
-sbuild-destroychroot (unconfined)
65
-sbuild-createchroot (unconfined)
66
-sbuild-clean (unconfined)
67
-sbuild-checkpackages (unconfined)
68
-sbuild-apt (unconfined)
69
-sbuild-adduser (unconfined)
70
-sbuild-abort (unconfined)
71
-sbuild (unconfined)
72
-runc (unconfined)
73
-rssguard (unconfined)
74
-rpm (unconfined)
75
-rootlesskit (unconfined)
76
-qutebrowser (unconfined)
77
-qmapshack (unconfined)
78
-qcam (unconfined)
79
-privacybrowser (unconfined)
80
-polypane (unconfined)
81
-podman (unconfined)
82
-plasmashell (enforce)
83
-plasmashell//QtWebEngineProcess (enforce)
84
-pageedit (unconfined)
85
-opera (unconfined)
86
-opam (unconfined)
87
-obsidian (unconfined)
88
-nvidia_modprobe (enforce)
89
-nvidia_modprobe//kmod (enforce)
90
-notepadqq (unconfined)
91
-nautilus (unconfined)
92
-msedge (unconfined)
93
-mmdebstrap (unconfined)
94
-lxc-usernsexec (unconfined)
95
-lxc-unshare (unconfined)
96
-lxc-stop (unconfined)
97
-lxc-execute (unconfined)
98
-lxc-destroy (unconfined)
99
-lxc-create (unconfined)
100
-lxc-attach (unconfined)
101
-lsb_release (enforce)
102
-loupe (unconfined)
103
-linux-sandbox (unconfined)
104
-libcamerify (unconfined)
105
-lc-compliance (unconfined)
106
-keybase (unconfined)
107
-kchmviewer (unconfined)
108
-ipa_verify (unconfined)
109
-goldendict (unconfined)
110
-github-desktop (unconfined)
111
-geary (unconfined)
112
-foliate (unconfined)
113
-flatpak (unconfined)
114
-firefox (unconfined)
115
-evolution (unconfined)
116
-epiphany (unconfined)
117
-element-desktop (unconfined)
118
-devhelp (unconfined)
119
-crun (unconfined)
120
-vscode (unconfined)
121
-chromium (unconfined)
122
-chrome (unconfined)
123
-ch-run (unconfined)
124
-ch-checkns (unconfined)
125
-cam (unconfined)
126
-busybox (unconfined)
127
-buildah (unconfined)
128
-brave (unconfined)
129
-balena-etcher (unconfined)
130
-Xorg (complain)
131
-QtWebEngineProcess (unconfined)
132
-MongoDB Compass (unconfined)
133
-Discord (unconfined)
134
-1password (unconfined)
135
-`
136
-
137
-func TestIsLoaded(t *testing.T) {
138
-	tmpDir := t.TempDir()
139
-	profiles := path.Join(tmpDir, "apparmor_profiles")
140
-	if err := os.WriteFile(profiles, []byte(testAppArmorProfiles), 0o644); err != nil {
141
-		t.Fatal(err)
142
-	}
143
-	t.Run("loaded", func(t *testing.T) {
144
-		found, err := isLoaded("busybox", profiles)
145
-		if err != nil {
146
-			t.Fatal(err)
147
-		}
148
-		if !found {
149
-			t.Fatal("expected profile to be loaded")
150
-		}
151
-	})
152
-	t.Run("not loaded", func(t *testing.T) {
153
-		found, err := isLoaded("no-such-profile", profiles)
154
-		if err != nil {
155
-			t.Fatal(err)
156
-		}
157
-		if found {
158
-			t.Fatal("expected profile to not be loaded")
159
-		}
160
-	})
161
-	t.Run("error", func(t *testing.T) {
162
-		_, err := isLoaded("anything", path.Join(tmpDir, "no_such_file"))
163
-		if err == nil || !errors.Is(err, os.ErrNotExist) {
164
-			t.Fatalf("expected error to be os.ErrNotExist, got %v", err)
165
-		}
166
-	})
167
-}
168
-
169
-func createTestProfiles(b *testing.B, lines int, targetProfile string) string {
170
-	b.Helper()
171
-
172
-	var sb strings.Builder
173
-	for i := 0; i < lines-1; i++ {
174
-		sb.WriteString("someprofile (enforcing)\n")
175
-	}
176
-	sb.WriteString(targetProfile + " (enforcing)\n")
177
-
178
-	fileName := filepath.Join(b.TempDir(), "apparmor_profiles")
179
-	if err := os.WriteFile(fileName, []byte(sb.String()), 0o644); err != nil {
180
-		b.Fatal(err)
181
-	}
182
-	return fileName
183
-}
184
-
185
-func BenchmarkIsLoaded(b *testing.B) {
186
-	const target = "myprofile"
187
-	profiles := createTestProfiles(b, 10000, target)
188
-
189
-	b.ReportAllocs()
190
-	b.ResetTimer()
191
-	for i := 0; i < b.N; i++ {
192
-		found, err := isLoaded(target, profiles)
193
-		if err != nil || !found {
194
-			b.Fatalf("expected profile to be found, got found=%v, err=%v", found, err)
195
-		}
196
-	}
197
-}
198 1
deleted file mode 100644
... ...
@@ -1,59 +0,0 @@
1
-//go:build linux
2
-
3
-package apparmor
4
-
5
-// NOTE: This profile is replicated in containerd and libpod. If you make a
6
-//       change to this profile, please make follow-up PRs to those projects so
7
-//       that these rules can be synchronised (because any issue with this
8
-//       profile will likely affect libpod and containerd).
9
-// TODO: Move this to a common project so we can maintain it in one spot.
10
-
11
-// baseTemplate defines the default apparmor profile for containers.
12
-const baseTemplate = `
13
-{{range $value := .Imports}}
14
-{{$value}}
15
-{{end}}
16
-
17
-profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
18
-{{range $value := .InnerImports}}
19
-  {{$value}}
20
-{{end}}
21
-
22
-  network,
23
-  capability,
24
-  file,
25
-  umount,
26
-  # Host (privileged) processes may send signals to container processes.
27
-  signal (receive) peer=unconfined,
28
-  # runc may send signals to container processes (for "docker stop").
29
-  signal (receive) peer=runc,
30
-  # crun may send signals to container processes (for "docker stop" when used with crun OCI runtime).
31
-  signal (receive) peer=crun,
32
-  # dockerd may send signals to container processes (for "docker kill").
33
-  signal (receive) peer={{.DaemonProfile}},
34
-  # Container processes may send signals amongst themselves.
35
-  signal (send,receive) peer={{.Name}},
36
-
37
-  deny @{PROC}/* w,   # deny write for all files directly in /proc (not in a subdir)
38
-  # deny write to files not in /proc/<number>/** or /proc/sys/**
39
-  deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9/]*}/** w,
40
-  deny @{PROC}/sys/[^k]** w,  # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
41
-  deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w,  # deny everything except shm* in /proc/sys/kernel/
42
-  deny @{PROC}/sysrq-trigger rwklx,
43
-  deny @{PROC}/kcore rwklx,
44
-
45
-  deny mount,
46
-
47
-  deny /sys/[^f]*/** wklx,
48
-  deny /sys/f[^s]*/** wklx,
49
-  deny /sys/fs/[^c]*/** wklx,
50
-  deny /sys/fs/c[^g]*/** wklx,
51
-  deny /sys/fs/cg[^r]*/** wklx,
52
-  deny /sys/firmware/** rwklx,
53
-  deny /sys/devices/virtual/powercap/** rwklx,
54
-  deny /sys/kernel/security/** rwklx,
55
-
56
-  # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
57
-  ptrace (trace,read,tracedby,readby) peer={{.Name}},
58
-}
59
-`
60 1
deleted file mode 100644
... ...
@@ -1,845 +0,0 @@
1
-{
2
-	"defaultAction": "SCMP_ACT_ERRNO",
3
-	"defaultErrnoRet": 1,
4
-	"archMap": [
5
-		{
6
-			"architecture": "SCMP_ARCH_X86_64",
7
-			"subArchitectures": [
8
-				"SCMP_ARCH_X86",
9
-				"SCMP_ARCH_X32"
10
-			]
11
-		},
12
-		{
13
-			"architecture": "SCMP_ARCH_AARCH64",
14
-			"subArchitectures": [
15
-				"SCMP_ARCH_ARM"
16
-			]
17
-		},
18
-		{
19
-			"architecture": "SCMP_ARCH_MIPS64",
20
-			"subArchitectures": [
21
-				"SCMP_ARCH_MIPS",
22
-				"SCMP_ARCH_MIPS64N32"
23
-			]
24
-		},
25
-		{
26
-			"architecture": "SCMP_ARCH_MIPS64N32",
27
-			"subArchitectures": [
28
-				"SCMP_ARCH_MIPS",
29
-				"SCMP_ARCH_MIPS64"
30
-			]
31
-		},
32
-		{
33
-			"architecture": "SCMP_ARCH_MIPSEL64",
34
-			"subArchitectures": [
35
-				"SCMP_ARCH_MIPSEL",
36
-				"SCMP_ARCH_MIPSEL64N32"
37
-			]
38
-		},
39
-		{
40
-			"architecture": "SCMP_ARCH_MIPSEL64N32",
41
-			"subArchitectures": [
42
-				"SCMP_ARCH_MIPSEL",
43
-				"SCMP_ARCH_MIPSEL64"
44
-			]
45
-		},
46
-		{
47
-			"architecture": "SCMP_ARCH_S390X",
48
-			"subArchitectures": [
49
-				"SCMP_ARCH_S390"
50
-			]
51
-		},
52
-		{
53
-			"architecture": "SCMP_ARCH_RISCV64",
54
-			"subArchitectures": null
55
-		}
56
-	],
57
-	"syscalls": [
58
-		{
59
-			"names": [
60
-				"accept",
61
-				"accept4",
62
-				"access",
63
-				"adjtimex",
64
-				"alarm",
65
-				"bind",
66
-				"brk",
67
-				"cachestat",
68
-				"capget",
69
-				"capset",
70
-				"chdir",
71
-				"chmod",
72
-				"chown",
73
-				"chown32",
74
-				"clock_adjtime",
75
-				"clock_adjtime64",
76
-				"clock_getres",
77
-				"clock_getres_time64",
78
-				"clock_gettime",
79
-				"clock_gettime64",
80
-				"clock_nanosleep",
81
-				"clock_nanosleep_time64",
82
-				"close",
83
-				"close_range",
84
-				"connect",
85
-				"copy_file_range",
86
-				"creat",
87
-				"dup",
88
-				"dup2",
89
-				"dup3",
90
-				"epoll_create",
91
-				"epoll_create1",
92
-				"epoll_ctl",
93
-				"epoll_ctl_old",
94
-				"epoll_pwait",
95
-				"epoll_pwait2",
96
-				"epoll_wait",
97
-				"epoll_wait_old",
98
-				"eventfd",
99
-				"eventfd2",
100
-				"execve",
101
-				"execveat",
102
-				"exit",
103
-				"exit_group",
104
-				"faccessat",
105
-				"faccessat2",
106
-				"fadvise64",
107
-				"fadvise64_64",
108
-				"fallocate",
109
-				"fanotify_mark",
110
-				"fchdir",
111
-				"fchmod",
112
-				"fchmodat",
113
-				"fchmodat2",
114
-				"fchown",
115
-				"fchown32",
116
-				"fchownat",
117
-				"fcntl",
118
-				"fcntl64",
119
-				"fdatasync",
120
-				"fgetxattr",
121
-				"flistxattr",
122
-				"flock",
123
-				"fork",
124
-				"fremovexattr",
125
-				"fsetxattr",
126
-				"fstat",
127
-				"fstat64",
128
-				"fstatat64",
129
-				"fstatfs",
130
-				"fstatfs64",
131
-				"fsync",
132
-				"ftruncate",
133
-				"ftruncate64",
134
-				"futex",
135
-				"futex_requeue",
136
-				"futex_time64",
137
-				"futex_wait",
138
-				"futex_waitv",
139
-				"futex_wake",
140
-				"futimesat",
141
-				"getcpu",
142
-				"getcwd",
143
-				"getdents",
144
-				"getdents64",
145
-				"getegid",
146
-				"getegid32",
147
-				"geteuid",
148
-				"geteuid32",
149
-				"getgid",
150
-				"getgid32",
151
-				"getgroups",
152
-				"getgroups32",
153
-				"getitimer",
154
-				"getpeername",
155
-				"getpgid",
156
-				"getpgrp",
157
-				"getpid",
158
-				"getppid",
159
-				"getpriority",
160
-				"getrandom",
161
-				"getresgid",
162
-				"getresgid32",
163
-				"getresuid",
164
-				"getresuid32",
165
-				"getrlimit",
166
-				"get_robust_list",
167
-				"getrusage",
168
-				"getsid",
169
-				"getsockname",
170
-				"getsockopt",
171
-				"get_thread_area",
172
-				"gettid",
173
-				"gettimeofday",
174
-				"getuid",
175
-				"getuid32",
176
-				"getxattr",
177
-				"getxattrat",
178
-				"inotify_add_watch",
179
-				"inotify_init",
180
-				"inotify_init1",
181
-				"inotify_rm_watch",
182
-				"io_cancel",
183
-				"ioctl",
184
-				"io_destroy",
185
-				"io_getevents",
186
-				"io_pgetevents",
187
-				"io_pgetevents_time64",
188
-				"ioprio_get",
189
-				"ioprio_set",
190
-				"io_setup",
191
-				"io_submit",
192
-				"ipc",
193
-				"kill",
194
-				"landlock_add_rule",
195
-				"landlock_create_ruleset",
196
-				"landlock_restrict_self",
197
-				"lchown",
198
-				"lchown32",
199
-				"lgetxattr",
200
-				"link",
201
-				"linkat",
202
-				"listen",
203
-				"listmount",
204
-				"listxattr",
205
-				"listxattrat",
206
-				"llistxattr",
207
-				"_llseek",
208
-				"lremovexattr",
209
-				"lseek",
210
-				"lsetxattr",
211
-				"lstat",
212
-				"lstat64",
213
-				"madvise",
214
-				"map_shadow_stack",
215
-				"membarrier",
216
-				"memfd_create",
217
-				"memfd_secret",
218
-				"mincore",
219
-				"mkdir",
220
-				"mkdirat",
221
-				"mknod",
222
-				"mknodat",
223
-				"mlock",
224
-				"mlock2",
225
-				"mlockall",
226
-				"mmap",
227
-				"mmap2",
228
-				"mprotect",
229
-				"mq_getsetattr",
230
-				"mq_notify",
231
-				"mq_open",
232
-				"mq_timedreceive",
233
-				"mq_timedreceive_time64",
234
-				"mq_timedsend",
235
-				"mq_timedsend_time64",
236
-				"mq_unlink",
237
-				"mremap",
238
-				"mseal",
239
-				"msgctl",
240
-				"msgget",
241
-				"msgrcv",
242
-				"msgsnd",
243
-				"msync",
244
-				"munlock",
245
-				"munlockall",
246
-				"munmap",
247
-				"name_to_handle_at",
248
-				"nanosleep",
249
-				"newfstatat",
250
-				"_newselect",
251
-				"open",
252
-				"openat",
253
-				"openat2",
254
-				"pause",
255
-				"pidfd_open",
256
-				"pidfd_send_signal",
257
-				"pipe",
258
-				"pipe2",
259
-				"pkey_alloc",
260
-				"pkey_free",
261
-				"pkey_mprotect",
262
-				"poll",
263
-				"ppoll",
264
-				"ppoll_time64",
265
-				"prctl",
266
-				"pread64",
267
-				"preadv",
268
-				"preadv2",
269
-				"prlimit64",
270
-				"process_mrelease",
271
-				"pselect6",
272
-				"pselect6_time64",
273
-				"pwrite64",
274
-				"pwritev",
275
-				"pwritev2",
276
-				"read",
277
-				"readahead",
278
-				"readlink",
279
-				"readlinkat",
280
-				"readv",
281
-				"recv",
282
-				"recvfrom",
283
-				"recvmmsg",
284
-				"recvmmsg_time64",
285
-				"recvmsg",
286
-				"remap_file_pages",
287
-				"removexattr",
288
-				"removexattrat",
289
-				"rename",
290
-				"renameat",
291
-				"renameat2",
292
-				"restart_syscall",
293
-				"riscv_hwprobe",
294
-				"rmdir",
295
-				"rseq",
296
-				"rt_sigaction",
297
-				"rt_sigpending",
298
-				"rt_sigprocmask",
299
-				"rt_sigqueueinfo",
300
-				"rt_sigreturn",
301
-				"rt_sigsuspend",
302
-				"rt_sigtimedwait",
303
-				"rt_sigtimedwait_time64",
304
-				"rt_tgsigqueueinfo",
305
-				"sched_getaffinity",
306
-				"sched_getattr",
307
-				"sched_getparam",
308
-				"sched_get_priority_max",
309
-				"sched_get_priority_min",
310
-				"sched_getscheduler",
311
-				"sched_rr_get_interval",
312
-				"sched_rr_get_interval_time64",
313
-				"sched_setaffinity",
314
-				"sched_setattr",
315
-				"sched_setparam",
316
-				"sched_setscheduler",
317
-				"sched_yield",
318
-				"seccomp",
319
-				"select",
320
-				"semctl",
321
-				"semget",
322
-				"semop",
323
-				"semtimedop",
324
-				"semtimedop_time64",
325
-				"send",
326
-				"sendfile",
327
-				"sendfile64",
328
-				"sendmmsg",
329
-				"sendmsg",
330
-				"sendto",
331
-				"setfsgid",
332
-				"setfsgid32",
333
-				"setfsuid",
334
-				"setfsuid32",
335
-				"setgid",
336
-				"setgid32",
337
-				"setgroups",
338
-				"setgroups32",
339
-				"setitimer",
340
-				"setpgid",
341
-				"setpriority",
342
-				"setregid",
343
-				"setregid32",
344
-				"setresgid",
345
-				"setresgid32",
346
-				"setresuid",
347
-				"setresuid32",
348
-				"setreuid",
349
-				"setreuid32",
350
-				"setrlimit",
351
-				"set_robust_list",
352
-				"setsid",
353
-				"setsockopt",
354
-				"set_thread_area",
355
-				"set_tid_address",
356
-				"setuid",
357
-				"setuid32",
358
-				"setxattr",
359
-				"setxattrat",
360
-				"shmat",
361
-				"shmctl",
362
-				"shmdt",
363
-				"shmget",
364
-				"shutdown",
365
-				"sigaltstack",
366
-				"signalfd",
367
-				"signalfd4",
368
-				"sigprocmask",
369
-				"sigreturn",
370
-				"socketcall",
371
-				"socketpair",
372
-				"splice",
373
-				"stat",
374
-				"stat64",
375
-				"statfs",
376
-				"statfs64",
377
-				"statmount",
378
-				"statx",
379
-				"symlink",
380
-				"symlinkat",
381
-				"sync",
382
-				"sync_file_range",
383
-				"syncfs",
384
-				"sysinfo",
385
-				"tee",
386
-				"tgkill",
387
-				"time",
388
-				"timer_create",
389
-				"timer_delete",
390
-				"timer_getoverrun",
391
-				"timer_gettime",
392
-				"timer_gettime64",
393
-				"timer_settime",
394
-				"timer_settime64",
395
-				"timerfd_create",
396
-				"timerfd_gettime",
397
-				"timerfd_gettime64",
398
-				"timerfd_settime",
399
-				"timerfd_settime64",
400
-				"times",
401
-				"tkill",
402
-				"truncate",
403
-				"truncate64",
404
-				"ugetrlimit",
405
-				"umask",
406
-				"uname",
407
-				"unlink",
408
-				"unlinkat",
409
-				"uretprobe",
410
-				"utime",
411
-				"utimensat",
412
-				"utimensat_time64",
413
-				"utimes",
414
-				"vfork",
415
-				"vmsplice",
416
-				"wait4",
417
-				"waitid",
418
-				"waitpid",
419
-				"write",
420
-				"writev"
421
-			],
422
-			"action": "SCMP_ACT_ALLOW"
423
-		},
424
-		{
425
-			"names": [
426
-				"process_vm_readv",
427
-				"process_vm_writev",
428
-				"ptrace"
429
-			],
430
-			"action": "SCMP_ACT_ALLOW",
431
-			"includes": {
432
-				"minKernel": "4.8"
433
-			}
434
-		},
435
-		{
436
-			"names": [
437
-				"socket"
438
-			],
439
-			"action": "SCMP_ACT_ALLOW",
440
-			"args": [
441
-				{
442
-					"index": 0,
443
-					"value": 40,
444
-					"op": "SCMP_CMP_NE"
445
-				}
446
-			]
447
-		},
448
-		{
449
-			"names": [
450
-				"personality"
451
-			],
452
-			"action": "SCMP_ACT_ALLOW",
453
-			"args": [
454
-				{
455
-					"index": 0,
456
-					"value": 0,
457
-					"op": "SCMP_CMP_EQ"
458
-				}
459
-			]
460
-		},
461
-		{
462
-			"names": [
463
-				"personality"
464
-			],
465
-			"action": "SCMP_ACT_ALLOW",
466
-			"args": [
467
-				{
468
-					"index": 0,
469
-					"value": 8,
470
-					"op": "SCMP_CMP_EQ"
471
-				}
472
-			]
473
-		},
474
-		{
475
-			"names": [
476
-				"personality"
477
-			],
478
-			"action": "SCMP_ACT_ALLOW",
479
-			"args": [
480
-				{
481
-					"index": 0,
482
-					"value": 131072,
483
-					"op": "SCMP_CMP_EQ"
484
-				}
485
-			]
486
-		},
487
-		{
488
-			"names": [
489
-				"personality"
490
-			],
491
-			"action": "SCMP_ACT_ALLOW",
492
-			"args": [
493
-				{
494
-					"index": 0,
495
-					"value": 131080,
496
-					"op": "SCMP_CMP_EQ"
497
-				}
498
-			]
499
-		},
500
-		{
501
-			"names": [
502
-				"personality"
503
-			],
504
-			"action": "SCMP_ACT_ALLOW",
505
-			"args": [
506
-				{
507
-					"index": 0,
508
-					"value": 4294967295,
509
-					"op": "SCMP_CMP_EQ"
510
-				}
511
-			]
512
-		},
513
-		{
514
-			"names": [
515
-				"sync_file_range2",
516
-				"swapcontext"
517
-			],
518
-			"action": "SCMP_ACT_ALLOW",
519
-			"includes": {
520
-				"arches": [
521
-					"ppc64le"
522
-				]
523
-			}
524
-		},
525
-		{
526
-			"names": [
527
-				"arm_fadvise64_64",
528
-				"arm_sync_file_range",
529
-				"sync_file_range2",
530
-				"breakpoint",
531
-				"cacheflush",
532
-				"set_tls"
533
-			],
534
-			"action": "SCMP_ACT_ALLOW",
535
-			"includes": {
536
-				"arches": [
537
-					"arm",
538
-					"arm64"
539
-				]
540
-			}
541
-		},
542
-		{
543
-			"names": [
544
-				"arch_prctl"
545
-			],
546
-			"action": "SCMP_ACT_ALLOW",
547
-			"includes": {
548
-				"arches": [
549
-					"amd64",
550
-					"x32"
551
-				]
552
-			}
553
-		},
554
-		{
555
-			"names": [
556
-				"modify_ldt"
557
-			],
558
-			"action": "SCMP_ACT_ALLOW",
559
-			"includes": {
560
-				"arches": [
561
-					"amd64",
562
-					"x32",
563
-					"x86"
564
-				]
565
-			}
566
-		},
567
-		{
568
-			"names": [
569
-				"s390_pci_mmio_read",
570
-				"s390_pci_mmio_write",
571
-				"s390_runtime_instr"
572
-			],
573
-			"action": "SCMP_ACT_ALLOW",
574
-			"includes": {
575
-				"arches": [
576
-					"s390",
577
-					"s390x"
578
-				]
579
-			}
580
-		},
581
-		{
582
-			"names": [
583
-				"riscv_flush_icache"
584
-			],
585
-			"action": "SCMP_ACT_ALLOW",
586
-			"includes": {
587
-				"arches": [
588
-					"riscv64"
589
-				]
590
-			}
591
-		},
592
-		{
593
-			"names": [
594
-				"open_by_handle_at"
595
-			],
596
-			"action": "SCMP_ACT_ALLOW",
597
-			"includes": {
598
-				"caps": [
599
-					"CAP_DAC_READ_SEARCH"
600
-				]
601
-			}
602
-		},
603
-		{
604
-			"names": [
605
-				"bpf",
606
-				"clone",
607
-				"clone3",
608
-				"fanotify_init",
609
-				"fsconfig",
610
-				"fsmount",
611
-				"fsopen",
612
-				"fspick",
613
-				"lookup_dcookie",
614
-				"lsm_get_self_attr",
615
-				"lsm_list_modules",
616
-				"lsm_set_self_attr",
617
-				"mount",
618
-				"mount_setattr",
619
-				"move_mount",
620
-				"open_tree",
621
-				"perf_event_open",
622
-				"quotactl",
623
-				"quotactl_fd",
624
-				"setdomainname",
625
-				"sethostname",
626
-				"setns",
627
-				"syslog",
628
-				"umount",
629
-				"umount2",
630
-				"unshare"
631
-			],
632
-			"action": "SCMP_ACT_ALLOW",
633
-			"includes": {
634
-				"caps": [
635
-					"CAP_SYS_ADMIN"
636
-				]
637
-			}
638
-		},
639
-		{
640
-			"names": [
641
-				"clone"
642
-			],
643
-			"action": "SCMP_ACT_ALLOW",
644
-			"args": [
645
-				{
646
-					"index": 0,
647
-					"value": 2114060288,
648
-					"op": "SCMP_CMP_MASKED_EQ"
649
-				}
650
-			],
651
-			"excludes": {
652
-				"caps": [
653
-					"CAP_SYS_ADMIN"
654
-				],
655
-				"arches": [
656
-					"s390",
657
-					"s390x"
658
-				]
659
-			}
660
-		},
661
-		{
662
-			"names": [
663
-				"clone"
664
-			],
665
-			"action": "SCMP_ACT_ALLOW",
666
-			"args": [
667
-				{
668
-					"index": 1,
669
-					"value": 2114060288,
670
-					"op": "SCMP_CMP_MASKED_EQ"
671
-				}
672
-			],
673
-			"comment": "s390 parameter ordering for clone is different",
674
-			"includes": {
675
-				"arches": [
676
-					"s390",
677
-					"s390x"
678
-				]
679
-			},
680
-			"excludes": {
681
-				"caps": [
682
-					"CAP_SYS_ADMIN"
683
-				]
684
-			}
685
-		},
686
-		{
687
-			"names": [
688
-				"clone3"
689
-			],
690
-			"action": "SCMP_ACT_ERRNO",
691
-			"errnoRet": 38,
692
-			"excludes": {
693
-				"caps": [
694
-					"CAP_SYS_ADMIN"
695
-				]
696
-			}
697
-		},
698
-		{
699
-			"names": [
700
-				"reboot"
701
-			],
702
-			"action": "SCMP_ACT_ALLOW",
703
-			"includes": {
704
-				"caps": [
705
-					"CAP_SYS_BOOT"
706
-				]
707
-			}
708
-		},
709
-		{
710
-			"names": [
711
-				"chroot"
712
-			],
713
-			"action": "SCMP_ACT_ALLOW",
714
-			"includes": {
715
-				"caps": [
716
-					"CAP_SYS_CHROOT"
717
-				]
718
-			}
719
-		},
720
-		{
721
-			"names": [
722
-				"delete_module",
723
-				"init_module",
724
-				"finit_module"
725
-			],
726
-			"action": "SCMP_ACT_ALLOW",
727
-			"includes": {
728
-				"caps": [
729
-					"CAP_SYS_MODULE"
730
-				]
731
-			}
732
-		},
733
-		{
734
-			"names": [
735
-				"acct"
736
-			],
737
-			"action": "SCMP_ACT_ALLOW",
738
-			"includes": {
739
-				"caps": [
740
-					"CAP_SYS_PACCT"
741
-				]
742
-			}
743
-		},
744
-		{
745
-			"names": [
746
-				"kcmp",
747
-				"pidfd_getfd",
748
-				"process_madvise",
749
-				"process_vm_readv",
750
-				"process_vm_writev",
751
-				"ptrace"
752
-			],
753
-			"action": "SCMP_ACT_ALLOW",
754
-			"includes": {
755
-				"caps": [
756
-					"CAP_SYS_PTRACE"
757
-				]
758
-			}
759
-		},
760
-		{
761
-			"names": [
762
-				"iopl",
763
-				"ioperm"
764
-			],
765
-			"action": "SCMP_ACT_ALLOW",
766
-			"includes": {
767
-				"caps": [
768
-					"CAP_SYS_RAWIO"
769
-				]
770
-			}
771
-		},
772
-		{
773
-			"names": [
774
-				"settimeofday",
775
-				"stime",
776
-				"clock_settime",
777
-				"clock_settime64"
778
-			],
779
-			"action": "SCMP_ACT_ALLOW",
780
-			"includes": {
781
-				"caps": [
782
-					"CAP_SYS_TIME"
783
-				]
784
-			}
785
-		},
786
-		{
787
-			"names": [
788
-				"vhangup"
789
-			],
790
-			"action": "SCMP_ACT_ALLOW",
791
-			"includes": {
792
-				"caps": [
793
-					"CAP_SYS_TTY_CONFIG"
794
-				]
795
-			}
796
-		},
797
-		{
798
-			"names": [
799
-				"get_mempolicy",
800
-				"mbind",
801
-				"set_mempolicy",
802
-				"set_mempolicy_home_node"
803
-			],
804
-			"action": "SCMP_ACT_ALLOW",
805
-			"includes": {
806
-				"caps": [
807
-					"CAP_SYS_NICE"
808
-				]
809
-			}
810
-		},
811
-		{
812
-			"names": [
813
-				"syslog"
814
-			],
815
-			"action": "SCMP_ACT_ALLOW",
816
-			"includes": {
817
-				"caps": [
818
-					"CAP_SYSLOG"
819
-				]
820
-			}
821
-		},
822
-		{
823
-			"names": [
824
-				"bpf"
825
-			],
826
-			"action": "SCMP_ACT_ALLOW",
827
-			"includes": {
828
-				"caps": [
829
-					"CAP_BPF"
830
-				]
831
-			}
832
-		},
833
-		{
834
-			"names": [
835
-				"perf_event_open"
836
-			],
837
-			"action": "SCMP_ACT_ALLOW",
838
-			"includes": {
839
-				"caps": [
840
-					"CAP_PERFMON"
841
-				]
842
-			}
843
-		}
844
-	]
845
-}
846 1
\ No newline at end of file
847 2
deleted file mode 100644
... ...
@@ -1,841 +0,0 @@
1
-package seccomp
2
-
3
-import (
4
-	"github.com/opencontainers/runtime-spec/specs-go"
5
-	"golang.org/x/sys/unix"
6
-)
7
-
8
-func arches() []Architecture {
9
-	return []Architecture{
10
-		{
11
-			Arch:      specs.ArchX86_64,
12
-			SubArches: []specs.Arch{specs.ArchX86, specs.ArchX32},
13
-		},
14
-		{
15
-			Arch:      specs.ArchAARCH64,
16
-			SubArches: []specs.Arch{specs.ArchARM},
17
-		},
18
-		{
19
-			Arch:      specs.ArchMIPS64,
20
-			SubArches: []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64N32},
21
-		},
22
-		{
23
-			Arch:      specs.ArchMIPS64N32,
24
-			SubArches: []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64},
25
-		},
26
-		{
27
-			Arch:      specs.ArchMIPSEL64,
28
-			SubArches: []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64N32},
29
-		},
30
-		{
31
-			Arch:      specs.ArchMIPSEL64N32,
32
-			SubArches: []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64},
33
-		},
34
-		{
35
-			Arch:      specs.ArchS390X,
36
-			SubArches: []specs.Arch{specs.ArchS390},
37
-		},
38
-		{
39
-			Arch:      specs.ArchRISCV64,
40
-			SubArches: nil,
41
-		},
42
-	}
43
-}
44
-
45
-// DefaultProfile defines the allowed syscalls for the default seccomp profile.
46
-func DefaultProfile() *Seccomp {
47
-	nosys := uint(unix.ENOSYS)
48
-	syscalls := []*Syscall{
49
-		{
50
-			LinuxSyscall: specs.LinuxSyscall{
51
-				Names: []string{
52
-					"accept",
53
-					"accept4",
54
-					"access",
55
-					"adjtimex",
56
-					"alarm",
57
-					"bind",
58
-					"brk",
59
-					"cachestat", // kernel v6.5, libseccomp v2.5.5
60
-					"capget",
61
-					"capset",
62
-					"chdir",
63
-					"chmod",
64
-					"chown",
65
-					"chown32",
66
-					"clock_adjtime",
67
-					"clock_adjtime64",
68
-					"clock_getres",
69
-					"clock_getres_time64",
70
-					"clock_gettime",
71
-					"clock_gettime64",
72
-					"clock_nanosleep",
73
-					"clock_nanosleep_time64",
74
-					"close",
75
-					"close_range",
76
-					"connect",
77
-					"copy_file_range",
78
-					"creat",
79
-					"dup",
80
-					"dup2",
81
-					"dup3",
82
-					"epoll_create",
83
-					"epoll_create1",
84
-					"epoll_ctl",
85
-					"epoll_ctl_old",
86
-					"epoll_pwait",
87
-					"epoll_pwait2",
88
-					"epoll_wait",
89
-					"epoll_wait_old",
90
-					"eventfd",
91
-					"eventfd2",
92
-					"execve",
93
-					"execveat",
94
-					"exit",
95
-					"exit_group",
96
-					"faccessat",
97
-					"faccessat2",
98
-					"fadvise64",
99
-					"fadvise64_64",
100
-					"fallocate",
101
-					"fanotify_mark",
102
-					"fchdir",
103
-					"fchmod",
104
-					"fchmodat",
105
-					"fchmodat2", // kernel v6.6, libseccomp v2.5.5
106
-					"fchown",
107
-					"fchown32",
108
-					"fchownat",
109
-					"fcntl",
110
-					"fcntl64",
111
-					"fdatasync",
112
-					"fgetxattr",
113
-					"flistxattr",
114
-					"flock",
115
-					"fork",
116
-					"fremovexattr",
117
-					"fsetxattr",
118
-					"fstat",
119
-					"fstat64",
120
-					"fstatat64",
121
-					"fstatfs",
122
-					"fstatfs64",
123
-					"fsync",
124
-					"ftruncate",
125
-					"ftruncate64",
126
-					"futex",
127
-					"futex_requeue", // kernel v6.7, libseccomp v2.5.5
128
-					"futex_time64",
129
-					"futex_wait", // kernel v6.7, libseccomp v2.5.5
130
-					"futex_waitv",
131
-					"futex_wake", // kernel v6.7, libseccomp v2.5.5
132
-					"futimesat",
133
-					"getcpu",
134
-					"getcwd",
135
-					"getdents",
136
-					"getdents64",
137
-					"getegid",
138
-					"getegid32",
139
-					"geteuid",
140
-					"geteuid32",
141
-					"getgid",
142
-					"getgid32",
143
-					"getgroups",
144
-					"getgroups32",
145
-					"getitimer",
146
-					"getpeername",
147
-					"getpgid",
148
-					"getpgrp",
149
-					"getpid",
150
-					"getppid",
151
-					"getpriority",
152
-					"getrandom",
153
-					"getresgid",
154
-					"getresgid32",
155
-					"getresuid",
156
-					"getresuid32",
157
-					"getrlimit",
158
-					"get_robust_list",
159
-					"getrusage",
160
-					"getsid",
161
-					"getsockname",
162
-					"getsockopt",
163
-					"get_thread_area",
164
-					"gettid",
165
-					"gettimeofday",
166
-					"getuid",
167
-					"getuid32",
168
-					"getxattr",
169
-					"getxattrat", // kernel v6.13, libseccomp v2.6.0
170
-					"inotify_add_watch",
171
-					"inotify_init",
172
-					"inotify_init1",
173
-					"inotify_rm_watch",
174
-					"io_cancel",
175
-					"ioctl",
176
-					"io_destroy",
177
-					"io_getevents",
178
-					"io_pgetevents",
179
-					"io_pgetevents_time64",
180
-					"ioprio_get",
181
-					"ioprio_set",
182
-					"io_setup",
183
-					"io_submit",
184
-					"ipc",
185
-					"kill",
186
-					"landlock_add_rule",
187
-					"landlock_create_ruleset",
188
-					"landlock_restrict_self",
189
-					"lchown",
190
-					"lchown32",
191
-					"lgetxattr",
192
-					"link",
193
-					"linkat",
194
-					"listen",
195
-					"listmount", // kernel v6.8, libseccomp v2.6.0
196
-					"listxattr",
197
-					"listxattrat", // kernel v6.13, libseccomp v2.6.0
198
-					"llistxattr",
199
-					"_llseek",
200
-					"lremovexattr",
201
-					"lseek",
202
-					"lsetxattr",
203
-					"lstat",
204
-					"lstat64",
205
-					"madvise",
206
-					"map_shadow_stack", // kernel v6.6, libseccomp v2.5.5
207
-					"membarrier",
208
-					"memfd_create",
209
-					"memfd_secret",
210
-					"mincore",
211
-					"mkdir",
212
-					"mkdirat",
213
-					"mknod",
214
-					"mknodat",
215
-					"mlock",
216
-					"mlock2",
217
-					"mlockall",
218
-					"mmap",
219
-					"mmap2",
220
-					"mprotect",
221
-					"mq_getsetattr",
222
-					"mq_notify",
223
-					"mq_open",
224
-					"mq_timedreceive",
225
-					"mq_timedreceive_time64",
226
-					"mq_timedsend",
227
-					"mq_timedsend_time64",
228
-					"mq_unlink",
229
-					"mremap",
230
-					"mseal", // kernel v6.9, libseccomp v2.6.0
231
-					"msgctl",
232
-					"msgget",
233
-					"msgrcv",
234
-					"msgsnd",
235
-					"msync",
236
-					"munlock",
237
-					"munlockall",
238
-					"munmap",
239
-					"name_to_handle_at",
240
-					"nanosleep",
241
-					"newfstatat",
242
-					"_newselect",
243
-					"open",
244
-					"openat",
245
-					"openat2",
246
-					"pause",
247
-					"pidfd_open",
248
-					"pidfd_send_signal",
249
-					"pipe",
250
-					"pipe2",
251
-					"pkey_alloc",
252
-					"pkey_free",
253
-					"pkey_mprotect",
254
-					"poll",
255
-					"ppoll",
256
-					"ppoll_time64",
257
-					"prctl",
258
-					"pread64",
259
-					"preadv",
260
-					"preadv2",
261
-					"prlimit64",
262
-					"process_mrelease",
263
-					"pselect6",
264
-					"pselect6_time64",
265
-					"pwrite64",
266
-					"pwritev",
267
-					"pwritev2",
268
-					"read",
269
-					"readahead",
270
-					"readlink",
271
-					"readlinkat",
272
-					"readv",
273
-					"recv",
274
-					"recvfrom",
275
-					"recvmmsg",
276
-					"recvmmsg_time64",
277
-					"recvmsg",
278
-					"remap_file_pages",
279
-					"removexattr",
280
-					"removexattrat", // kernel v6.13, libseccomp v2.6.0
281
-					"rename",
282
-					"renameat",
283
-					"renameat2",
284
-					"restart_syscall",
285
-					"riscv_hwprobe", // kernel v6.12, libseccomp v2.6.0
286
-					"rmdir",
287
-					"rseq",
288
-					"rt_sigaction",
289
-					"rt_sigpending",
290
-					"rt_sigprocmask",
291
-					"rt_sigqueueinfo",
292
-					"rt_sigreturn",
293
-					"rt_sigsuspend",
294
-					"rt_sigtimedwait",
295
-					"rt_sigtimedwait_time64",
296
-					"rt_tgsigqueueinfo",
297
-					"sched_getaffinity",
298
-					"sched_getattr",
299
-					"sched_getparam",
300
-					"sched_get_priority_max",
301
-					"sched_get_priority_min",
302
-					"sched_getscheduler",
303
-					"sched_rr_get_interval",
304
-					"sched_rr_get_interval_time64",
305
-					"sched_setaffinity",
306
-					"sched_setattr",
307
-					"sched_setparam",
308
-					"sched_setscheduler",
309
-					"sched_yield",
310
-					"seccomp",
311
-					"select",
312
-					"semctl",
313
-					"semget",
314
-					"semop",
315
-					"semtimedop",
316
-					"semtimedop_time64",
317
-					"send",
318
-					"sendfile",
319
-					"sendfile64",
320
-					"sendmmsg",
321
-					"sendmsg",
322
-					"sendto",
323
-					"setfsgid",
324
-					"setfsgid32",
325
-					"setfsuid",
326
-					"setfsuid32",
327
-					"setgid",
328
-					"setgid32",
329
-					"setgroups",
330
-					"setgroups32",
331
-					"setitimer",
332
-					"setpgid",
333
-					"setpriority",
334
-					"setregid",
335
-					"setregid32",
336
-					"setresgid",
337
-					"setresgid32",
338
-					"setresuid",
339
-					"setresuid32",
340
-					"setreuid",
341
-					"setreuid32",
342
-					"setrlimit",
343
-					"set_robust_list",
344
-					"setsid",
345
-					"setsockopt",
346
-					"set_thread_area",
347
-					"set_tid_address",
348
-					"setuid",
349
-					"setuid32",
350
-					"setxattr",
351
-					"setxattrat", // kernel v6.13, libseccomp v2.6.0
352
-					"shmat",
353
-					"shmctl",
354
-					"shmdt",
355
-					"shmget",
356
-					"shutdown",
357
-					"sigaltstack",
358
-					"signalfd",
359
-					"signalfd4",
360
-					"sigprocmask",
361
-					"sigreturn",
362
-					"socketcall",
363
-					"socketpair",
364
-					"splice",
365
-					"stat",
366
-					"stat64",
367
-					"statfs",
368
-					"statfs64",
369
-					"statmount", // kernel v6.8, libseccomp v2.6.0
370
-					"statx",
371
-					"symlink",
372
-					"symlinkat",
373
-					"sync",
374
-					"sync_file_range",
375
-					"syncfs",
376
-					"sysinfo",
377
-					"tee",
378
-					"tgkill",
379
-					"time",
380
-					"timer_create",
381
-					"timer_delete",
382
-					"timer_getoverrun",
383
-					"timer_gettime",
384
-					"timer_gettime64",
385
-					"timer_settime",
386
-					"timer_settime64",
387
-					"timerfd_create",
388
-					"timerfd_gettime",
389
-					"timerfd_gettime64",
390
-					"timerfd_settime",
391
-					"timerfd_settime64",
392
-					"times",
393
-					"tkill",
394
-					"truncate",
395
-					"truncate64",
396
-					"ugetrlimit",
397
-					"umask",
398
-					"uname",
399
-					"unlink",
400
-					"unlinkat",
401
-					"uretprobe", // kernel v6.11, libseccomp v2.6.0
402
-					"utime",
403
-					"utimensat",
404
-					"utimensat_time64",
405
-					"utimes",
406
-					"vfork",
407
-					"vmsplice",
408
-					"wait4",
409
-					"waitid",
410
-					"waitpid",
411
-					"write",
412
-					"writev",
413
-				},
414
-				Action: specs.ActAllow,
415
-			},
416
-		},
417
-		{
418
-			LinuxSyscall: specs.LinuxSyscall{
419
-				Names: []string{
420
-					"process_vm_readv",
421
-					"process_vm_writev",
422
-					"ptrace",
423
-				},
424
-				Action: specs.ActAllow,
425
-			},
426
-			Includes: &Filter{
427
-				MinKernel: &KernelVersion{4, 8},
428
-			},
429
-		},
430
-		{
431
-			LinuxSyscall: specs.LinuxSyscall{
432
-				Names:  []string{"socket"},
433
-				Action: specs.ActAllow,
434
-				Args: []specs.LinuxSeccompArg{
435
-					{
436
-						Index: 0,
437
-						Value: unix.AF_VSOCK,
438
-						Op:    specs.OpNotEqual,
439
-					},
440
-				},
441
-			},
442
-		},
443
-		{
444
-			LinuxSyscall: specs.LinuxSyscall{
445
-				Names:  []string{"personality"},
446
-				Action: specs.ActAllow,
447
-				Args: []specs.LinuxSeccompArg{
448
-					{
449
-						Index: 0,
450
-						Value: 0x0,
451
-						Op:    specs.OpEqualTo,
452
-					},
453
-				},
454
-			},
455
-		},
456
-		{
457
-			LinuxSyscall: specs.LinuxSyscall{
458
-				Names:  []string{"personality"},
459
-				Action: specs.ActAllow,
460
-				Args: []specs.LinuxSeccompArg{
461
-					{
462
-						Index: 0,
463
-						Value: 0x0008,
464
-						Op:    specs.OpEqualTo,
465
-					},
466
-				},
467
-			},
468
-		},
469
-		{
470
-			LinuxSyscall: specs.LinuxSyscall{
471
-				Names:  []string{"personality"},
472
-				Action: specs.ActAllow,
473
-				Args: []specs.LinuxSeccompArg{
474
-					{
475
-						Index: 0,
476
-						Value: 0x20000,
477
-						Op:    specs.OpEqualTo,
478
-					},
479
-				},
480
-			},
481
-		},
482
-		{
483
-			LinuxSyscall: specs.LinuxSyscall{
484
-				Names:  []string{"personality"},
485
-				Action: specs.ActAllow,
486
-				Args: []specs.LinuxSeccompArg{
487
-					{
488
-						Index: 0,
489
-						Value: 0x20008,
490
-						Op:    specs.OpEqualTo,
491
-					},
492
-				},
493
-			},
494
-		},
495
-		{
496
-			LinuxSyscall: specs.LinuxSyscall{
497
-				Names:  []string{"personality"},
498
-				Action: specs.ActAllow,
499
-				Args: []specs.LinuxSeccompArg{
500
-					{
501
-						Index: 0,
502
-						Value: 0xffffffff,
503
-						Op:    specs.OpEqualTo,
504
-					},
505
-				},
506
-			},
507
-		},
508
-		{
509
-			LinuxSyscall: specs.LinuxSyscall{
510
-				Names: []string{
511
-					"sync_file_range2",
512
-					"swapcontext",
513
-				},
514
-				Action: specs.ActAllow,
515
-			},
516
-			Includes: &Filter{
517
-				Arches: []string{"ppc64le"},
518
-			},
519
-		},
520
-		{
521
-			LinuxSyscall: specs.LinuxSyscall{
522
-				Names: []string{
523
-					"arm_fadvise64_64",
524
-					"arm_sync_file_range",
525
-					"sync_file_range2",
526
-					"breakpoint",
527
-					"cacheflush",
528
-					"set_tls",
529
-				},
530
-				Action: specs.ActAllow,
531
-			},
532
-			Includes: &Filter{
533
-				Arches: []string{"arm", "arm64"},
534
-			},
535
-		},
536
-		{
537
-			LinuxSyscall: specs.LinuxSyscall{
538
-				Names: []string{
539
-					"arch_prctl",
540
-				},
541
-				Action: specs.ActAllow,
542
-			},
543
-			Includes: &Filter{
544
-				Arches: []string{"amd64", "x32"},
545
-			},
546
-		},
547
-		{
548
-			LinuxSyscall: specs.LinuxSyscall{
549
-				Names: []string{
550
-					"modify_ldt",
551
-				},
552
-				Action: specs.ActAllow,
553
-			},
554
-			Includes: &Filter{
555
-				Arches: []string{"amd64", "x32", "x86"},
556
-			},
557
-		},
558
-		{
559
-			LinuxSyscall: specs.LinuxSyscall{
560
-				Names: []string{
561
-					"s390_pci_mmio_read",
562
-					"s390_pci_mmio_write",
563
-					"s390_runtime_instr",
564
-				},
565
-				Action: specs.ActAllow,
566
-			},
567
-			Includes: &Filter{
568
-				Arches: []string{"s390", "s390x"},
569
-			},
570
-		},
571
-		{
572
-			LinuxSyscall: specs.LinuxSyscall{
573
-				Names: []string{
574
-					"riscv_flush_icache",
575
-				},
576
-				Action: specs.ActAllow,
577
-			},
578
-			Includes: &Filter{
579
-				Arches: []string{"riscv64"},
580
-			},
581
-		},
582
-		{
583
-			LinuxSyscall: specs.LinuxSyscall{
584
-				Names: []string{
585
-					"open_by_handle_at",
586
-				},
587
-				Action: specs.ActAllow,
588
-			},
589
-			Includes: &Filter{
590
-				Caps: []string{"CAP_DAC_READ_SEARCH"},
591
-			},
592
-		},
593
-		{
594
-			LinuxSyscall: specs.LinuxSyscall{
595
-				Names: []string{
596
-					"bpf",
597
-					"clone",
598
-					"clone3",
599
-					"fanotify_init",
600
-					"fsconfig",
601
-					"fsmount",
602
-					"fsopen",
603
-					"fspick",
604
-					"lookup_dcookie",
605
-					"lsm_get_self_attr", // kernel v6.8, libseccomp v2.6.0
606
-					"lsm_list_modules",  // kernel v6.8, libseccomp v2.6.0
607
-					"lsm_set_self_attr", // kernel v6.8, libseccomp v2.6.0
608
-					"mount",
609
-					"mount_setattr",
610
-					"move_mount",
611
-					"open_tree",
612
-					"perf_event_open",
613
-					"quotactl",
614
-					"quotactl_fd",
615
-					"setdomainname",
616
-					"sethostname",
617
-					"setns",
618
-					"syslog",
619
-					"umount",
620
-					"umount2",
621
-					"unshare",
622
-				},
623
-				Action: specs.ActAllow,
624
-			},
625
-			Includes: &Filter{
626
-				Caps: []string{"CAP_SYS_ADMIN"},
627
-			},
628
-		},
629
-		{
630
-			LinuxSyscall: specs.LinuxSyscall{
631
-				Names: []string{
632
-					"clone",
633
-				},
634
-				Action: specs.ActAllow,
635
-				Args: []specs.LinuxSeccompArg{
636
-					{
637
-						Index:    0,
638
-						Value:    unix.CLONE_NEWNS | unix.CLONE_NEWUTS | unix.CLONE_NEWIPC | unix.CLONE_NEWUSER | unix.CLONE_NEWPID | unix.CLONE_NEWNET | unix.CLONE_NEWCGROUP,
639
-						ValueTwo: 0,
640
-						Op:       specs.OpMaskedEqual,
641
-					},
642
-				},
643
-			},
644
-			Excludes: &Filter{
645
-				Caps:   []string{"CAP_SYS_ADMIN"},
646
-				Arches: []string{"s390", "s390x"},
647
-			},
648
-		},
649
-		{
650
-			LinuxSyscall: specs.LinuxSyscall{
651
-				Names: []string{
652
-					"clone",
653
-				},
654
-				Action: specs.ActAllow,
655
-				Args: []specs.LinuxSeccompArg{
656
-					{
657
-						Index:    1,
658
-						Value:    unix.CLONE_NEWNS | unix.CLONE_NEWUTS | unix.CLONE_NEWIPC | unix.CLONE_NEWUSER | unix.CLONE_NEWPID | unix.CLONE_NEWNET | unix.CLONE_NEWCGROUP,
659
-						ValueTwo: 0,
660
-						Op:       specs.OpMaskedEqual,
661
-					},
662
-				},
663
-			},
664
-			Comment: "s390 parameter ordering for clone is different",
665
-			Includes: &Filter{
666
-				Arches: []string{"s390", "s390x"},
667
-			},
668
-			Excludes: &Filter{
669
-				Caps: []string{"CAP_SYS_ADMIN"},
670
-			},
671
-		},
672
-		{
673
-			LinuxSyscall: specs.LinuxSyscall{
674
-				Names: []string{
675
-					"clone3",
676
-				},
677
-				Action:   specs.ActErrno,
678
-				ErrnoRet: &nosys,
679
-			},
680
-			Excludes: &Filter{
681
-				Caps: []string{"CAP_SYS_ADMIN"},
682
-			},
683
-		},
684
-		{
685
-			LinuxSyscall: specs.LinuxSyscall{
686
-				Names: []string{
687
-					"reboot",
688
-				},
689
-				Action: specs.ActAllow,
690
-			},
691
-			Includes: &Filter{
692
-				Caps: []string{"CAP_SYS_BOOT"},
693
-			},
694
-		},
695
-		{
696
-			LinuxSyscall: specs.LinuxSyscall{
697
-				Names: []string{
698
-					"chroot",
699
-				},
700
-				Action: specs.ActAllow,
701
-			},
702
-			Includes: &Filter{
703
-				Caps: []string{"CAP_SYS_CHROOT"},
704
-			},
705
-		},
706
-		{
707
-			LinuxSyscall: specs.LinuxSyscall{
708
-				Names: []string{
709
-					"delete_module",
710
-					"init_module",
711
-					"finit_module",
712
-				},
713
-				Action: specs.ActAllow,
714
-			},
715
-			Includes: &Filter{
716
-				Caps: []string{"CAP_SYS_MODULE"},
717
-			},
718
-		},
719
-		{
720
-			LinuxSyscall: specs.LinuxSyscall{
721
-				Names: []string{
722
-					"acct",
723
-				},
724
-				Action: specs.ActAllow,
725
-			},
726
-			Includes: &Filter{
727
-				Caps: []string{"CAP_SYS_PACCT"},
728
-			},
729
-		},
730
-		{
731
-			LinuxSyscall: specs.LinuxSyscall{
732
-				Names: []string{
733
-					"kcmp",
734
-					"pidfd_getfd",
735
-					"process_madvise",
736
-					"process_vm_readv",
737
-					"process_vm_writev",
738
-					"ptrace",
739
-				},
740
-				Action: specs.ActAllow,
741
-			},
742
-			Includes: &Filter{
743
-				Caps: []string{"CAP_SYS_PTRACE"},
744
-			},
745
-		},
746
-		{
747
-			LinuxSyscall: specs.LinuxSyscall{
748
-				Names: []string{
749
-					"iopl",
750
-					"ioperm",
751
-				},
752
-				Action: specs.ActAllow,
753
-			},
754
-			Includes: &Filter{
755
-				Caps: []string{"CAP_SYS_RAWIO"},
756
-			},
757
-		},
758
-		{
759
-			LinuxSyscall: specs.LinuxSyscall{
760
-				Names: []string{
761
-					"settimeofday",
762
-					"stime",
763
-					"clock_settime",
764
-					"clock_settime64",
765
-				},
766
-				Action: specs.ActAllow,
767
-			},
768
-			Includes: &Filter{
769
-				Caps: []string{"CAP_SYS_TIME"},
770
-			},
771
-		},
772
-		{
773
-			LinuxSyscall: specs.LinuxSyscall{
774
-				Names: []string{
775
-					"vhangup",
776
-				},
777
-				Action: specs.ActAllow,
778
-			},
779
-			Includes: &Filter{
780
-				Caps: []string{"CAP_SYS_TTY_CONFIG"},
781
-			},
782
-		},
783
-		{
784
-			LinuxSyscall: specs.LinuxSyscall{
785
-				Names: []string{
786
-					"get_mempolicy",
787
-					"mbind",
788
-					"set_mempolicy",
789
-					"set_mempolicy_home_node", // kernel v5.17, libseccomp v2.5.4
790
-				},
791
-				Action: specs.ActAllow,
792
-			},
793
-			Includes: &Filter{
794
-				Caps: []string{"CAP_SYS_NICE"},
795
-			},
796
-		},
797
-		{
798
-			LinuxSyscall: specs.LinuxSyscall{
799
-				Names: []string{
800
-					"syslog",
801
-				},
802
-				Action: specs.ActAllow,
803
-			},
804
-			Includes: &Filter{
805
-				Caps: []string{"CAP_SYSLOG"},
806
-			},
807
-		},
808
-		{
809
-			LinuxSyscall: specs.LinuxSyscall{
810
-				Names: []string{
811
-					"bpf",
812
-				},
813
-				Action: specs.ActAllow,
814
-			},
815
-			Includes: &Filter{
816
-				Caps: []string{"CAP_BPF"},
817
-			},
818
-		},
819
-		{
820
-			LinuxSyscall: specs.LinuxSyscall{
821
-				Names: []string{
822
-					"perf_event_open",
823
-				},
824
-				Action: specs.ActAllow,
825
-			},
826
-			Includes: &Filter{
827
-				Caps: []string{"CAP_PERFMON"},
828
-			},
829
-		},
830
-	}
831
-
832
-	errnoRet := uint(unix.EPERM)
833
-	return &Seccomp{
834
-		LinuxSeccomp: specs.LinuxSeccomp{
835
-			DefaultAction:   specs.ActErrno,
836
-			DefaultErrnoRet: &errnoRet,
837
-		},
838
-		ArchMap:  arches(),
839
-		Syscalls: syscalls,
840
-	}
841
-}
842 1
deleted file mode 100644
... ...
@@ -1,23 +0,0 @@
1
-{
2
-  "defaultAction": "SCMP_ACT_ERRNO",
3
-  "syscalls": [
4
-    {
5
-      "names": ["chmod"],
6
-      "action": "SCMP_ACT_ALLOW"
7
-    },
8
-    {
9
-      "names": ["syslog"],
10
-      "action": "SCMP_ACT_ALLOW",
11
-      "includes": {
12
-        "caps": ["CAP_SYSLOG"]
13
-      }
14
-    },
15
-    {
16
-      "names": ["ptrace"],
17
-      "action": "SCMP_ACT_ALLOW",
18
-      "excludes": {
19
-        "caps": ["CAP_SYS_ADMIN"]
20
-      }
21
-    }
22
-  ]
23
-}
24 1
deleted file mode 100644
... ...
@@ -1,1593 +0,0 @@
1
-{
2
-  "defaultAction": "SCMP_ACT_ERRNO",
3
-  "architectures": [
4
-    "SCMP_ARCH_X86_64",
5
-    "SCMP_ARCH_X86",
6
-    "SCMP_ARCH_X32"
7
-  ],
8
-  "syscalls": [
9
-    {
10
-      "name": "accept",
11
-      "action": "SCMP_ACT_ALLOW",
12
-      "args": []
13
-    },
14
-    {
15
-      "name": "accept4",
16
-      "action": "SCMP_ACT_ALLOW",
17
-      "args": []
18
-    },
19
-    {
20
-      "name": "access",
21
-      "action": "SCMP_ACT_ALLOW",
22
-      "args": []
23
-    },
24
-    {
25
-      "name": "alarm",
26
-      "action": "SCMP_ACT_ALLOW",
27
-      "args": []
28
-    },
29
-    {
30
-      "name": "bind",
31
-      "action": "SCMP_ACT_ALLOW",
32
-      "args": []
33
-    },
34
-    {
35
-      "name": "brk",
36
-      "action": "SCMP_ACT_ALLOW",
37
-      "args": []
38
-    },
39
-    {
40
-      "name": "capget",
41
-      "action": "SCMP_ACT_ALLOW",
42
-      "args": []
43
-    },
44
-    {
45
-      "name": "capset",
46
-      "action": "SCMP_ACT_ALLOW",
47
-      "args": []
48
-    },
49
-    {
50
-      "name": "chdir",
51
-      "action": "SCMP_ACT_ALLOW",
52
-      "args": []
53
-    },
54
-    {
55
-      "name": "chmod",
56
-      "action": "SCMP_ACT_ALLOW",
57
-      "args": []
58
-    },
59
-    {
60
-      "name": "chown",
61
-      "action": "SCMP_ACT_ALLOW",
62
-      "args": []
63
-    },
64
-    {
65
-      "name": "chown32",
66
-      "action": "SCMP_ACT_ALLOW",
67
-      "args": []
68
-    },
69
-    {
70
-      "name": "clock_getres",
71
-      "action": "SCMP_ACT_ALLOW",
72
-      "args": []
73
-    },
74
-    {
75
-      "name": "clock_gettime",
76
-      "action": "SCMP_ACT_ALLOW",
77
-      "args": []
78
-    },
79
-    {
80
-      "name": "clock_nanosleep",
81
-      "action": "SCMP_ACT_ALLOW",
82
-      "args": []
83
-    },
84
-    {
85
-      "name": "close",
86
-      "action": "SCMP_ACT_ALLOW",
87
-      "args": []
88
-    },
89
-    {
90
-      "name": "connect",
91
-      "action": "SCMP_ACT_ALLOW",
92
-      "args": []
93
-    },
94
-    {
95
-      "name": "copy_file_range",
96
-      "action": "SCMP_ACT_ALLOW",
97
-      "args": []
98
-    },
99
-    {
100
-      "name": "creat",
101
-      "action": "SCMP_ACT_ALLOW",
102
-      "args": []
103
-    },
104
-    {
105
-      "name": "dup",
106
-      "action": "SCMP_ACT_ALLOW",
107
-      "args": []
108
-    },
109
-    {
110
-      "name": "dup2",
111
-      "action": "SCMP_ACT_ALLOW",
112
-      "args": []
113
-    },
114
-    {
115
-      "name": "dup3",
116
-      "action": "SCMP_ACT_ALLOW",
117
-      "args": []
118
-    },
119
-    {
120
-      "name": "epoll_create",
121
-      "action": "SCMP_ACT_ALLOW",
122
-      "args": []
123
-    },
124
-    {
125
-      "name": "epoll_create1",
126
-      "action": "SCMP_ACT_ALLOW",
127
-      "args": []
128
-    },
129
-    {
130
-      "name": "epoll_ctl",
131
-      "action": "SCMP_ACT_ALLOW",
132
-      "args": []
133
-    },
134
-    {
135
-      "name": "epoll_ctl_old",
136
-      "action": "SCMP_ACT_ALLOW",
137
-      "args": []
138
-    },
139
-    {
140
-      "name": "epoll_pwait",
141
-      "action": "SCMP_ACT_ALLOW",
142
-      "args": []
143
-    },
144
-    {
145
-      "name": "epoll_wait",
146
-      "action": "SCMP_ACT_ALLOW",
147
-      "args": []
148
-    },
149
-    {
150
-      "name": "epoll_wait_old",
151
-      "action": "SCMP_ACT_ALLOW",
152
-      "args": []
153
-    },
154
-    {
155
-      "name": "eventfd",
156
-      "action": "SCMP_ACT_ALLOW",
157
-      "args": []
158
-    },
159
-    {
160
-      "name": "eventfd2",
161
-      "action": "SCMP_ACT_ALLOW",
162
-      "args": []
163
-    },
164
-    {
165
-      "name": "execve",
166
-      "action": "SCMP_ACT_ALLOW",
167
-      "args": []
168
-    },
169
-    {
170
-      "name": "execveat",
171
-      "action": "SCMP_ACT_ALLOW",
172
-      "args": []
173
-    },
174
-    {
175
-      "name": "exit",
176
-      "action": "SCMP_ACT_ALLOW",
177
-      "args": []
178
-    },
179
-    {
180
-      "name": "exit_group",
181
-      "action": "SCMP_ACT_ALLOW",
182
-      "args": []
183
-    },
184
-    {
185
-      "name": "faccessat",
186
-      "action": "SCMP_ACT_ALLOW",
187
-      "args": []
188
-    },
189
-    {
190
-      "name": "fadvise64",
191
-      "action": "SCMP_ACT_ALLOW",
192
-      "args": []
193
-    },
194
-    {
195
-      "name": "fadvise64_64",
196
-      "action": "SCMP_ACT_ALLOW",
197
-      "args": []
198
-    },
199
-    {
200
-      "name": "fallocate",
201
-      "action": "SCMP_ACT_ALLOW",
202
-      "args": []
203
-    },
204
-    {
205
-      "name": "fanotify_mark",
206
-      "action": "SCMP_ACT_ALLOW",
207
-      "args": []
208
-    },
209
-    {
210
-      "name": "fchdir",
211
-      "action": "SCMP_ACT_ALLOW",
212
-      "args": []
213
-    },
214
-    {
215
-      "name": "fchmod",
216
-      "action": "SCMP_ACT_ALLOW",
217
-      "args": []
218
-    },
219
-    {
220
-      "name": "fchmodat",
221
-      "action": "SCMP_ACT_ALLOW",
222
-      "args": []
223
-    },
224
-    {
225
-      "name": "fchown",
226
-      "action": "SCMP_ACT_ALLOW",
227
-      "args": []
228
-    },
229
-    {
230
-      "name": "fchown32",
231
-      "action": "SCMP_ACT_ALLOW",
232
-      "args": []
233
-    },
234
-    {
235
-      "name": "fchownat",
236
-      "action": "SCMP_ACT_ALLOW",
237
-      "args": []
238
-    },
239
-    {
240
-      "name": "fcntl",
241
-      "action": "SCMP_ACT_ALLOW",
242
-      "args": []
243
-    },
244
-    {
245
-      "name": "fcntl64",
246
-      "action": "SCMP_ACT_ALLOW",
247
-      "args": []
248
-    },
249
-    {
250
-      "name": "fdatasync",
251
-      "action": "SCMP_ACT_ALLOW",
252
-      "args": []
253
-    },
254
-    {
255
-      "name": "fgetxattr",
256
-      "action": "SCMP_ACT_ALLOW",
257
-      "args": []
258
-    },
259
-    {
260
-      "name": "flistxattr",
261
-      "action": "SCMP_ACT_ALLOW",
262
-      "args": []
263
-    },
264
-    {
265
-      "name": "flock",
266
-      "action": "SCMP_ACT_ALLOW",
267
-      "args": []
268
-    },
269
-    {
270
-      "name": "fork",
271
-      "action": "SCMP_ACT_ALLOW",
272
-      "args": []
273
-    },
274
-    {
275
-      "name": "fremovexattr",
276
-      "action": "SCMP_ACT_ALLOW",
277
-      "args": []
278
-    },
279
-    {
280
-      "name": "fsetxattr",
281
-      "action": "SCMP_ACT_ALLOW",
282
-      "args": []
283
-    },
284
-    {
285
-      "name": "fstat",
286
-      "action": "SCMP_ACT_ALLOW",
287
-      "args": []
288
-    },
289
-    {
290
-      "name": "fstat64",
291
-      "action": "SCMP_ACT_ALLOW",
292
-      "args": []
293
-    },
294
-    {
295
-      "name": "fstatat64",
296
-      "action": "SCMP_ACT_ALLOW",
297
-      "args": []
298
-    },
299
-    {
300
-      "name": "fstatfs",
301
-      "action": "SCMP_ACT_ALLOW",
302
-      "args": []
303
-    },
304
-    {
305
-      "name": "fstatfs64",
306
-      "action": "SCMP_ACT_ALLOW",
307
-      "args": []
308
-    },
309
-    {
310
-      "name": "fsync",
311
-      "action": "SCMP_ACT_ALLOW",
312
-      "args": []
313
-    },
314
-    {
315
-      "name": "ftruncate",
316
-      "action": "SCMP_ACT_ALLOW",
317
-      "args": []
318
-    },
319
-    {
320
-      "name": "ftruncate64",
321
-      "action": "SCMP_ACT_ALLOW",
322
-      "args": []
323
-    },
324
-    {
325
-      "name": "futex",
326
-      "action": "SCMP_ACT_ALLOW",
327
-      "args": []
328
-    },
329
-    {
330
-      "name": "futimesat",
331
-      "action": "SCMP_ACT_ALLOW",
332
-      "args": []
333
-    },
334
-    {
335
-      "name": "getcpu",
336
-      "action": "SCMP_ACT_ALLOW",
337
-      "args": []
338
-    },
339
-    {
340
-      "name": "getcwd",
341
-      "action": "SCMP_ACT_ALLOW",
342
-      "args": []
343
-    },
344
-    {
345
-      "name": "getdents",
346
-      "action": "SCMP_ACT_ALLOW",
347
-      "args": []
348
-    },
349
-    {
350
-      "name": "getdents64",
351
-      "action": "SCMP_ACT_ALLOW",
352
-      "args": []
353
-    },
354
-    {
355
-      "name": "getegid",
356
-      "action": "SCMP_ACT_ALLOW",
357
-      "args": []
358
-    },
359
-    {
360
-      "name": "getegid32",
361
-      "action": "SCMP_ACT_ALLOW",
362
-      "args": []
363
-    },
364
-    {
365
-      "name": "geteuid",
366
-      "action": "SCMP_ACT_ALLOW",
367
-      "args": []
368
-    },
369
-    {
370
-      "name": "geteuid32",
371
-      "action": "SCMP_ACT_ALLOW",
372
-      "args": []
373
-    },
374
-    {
375
-      "name": "getgid",
376
-      "action": "SCMP_ACT_ALLOW",
377
-      "args": []
378
-    },
379
-    {
380
-      "name": "getgid32",
381
-      "action": "SCMP_ACT_ALLOW",
382
-      "args": []
383
-    },
384
-    {
385
-      "name": "getgroups",
386
-      "action": "SCMP_ACT_ALLOW",
387
-      "args": []
388
-    },
389
-    {
390
-      "name": "getgroups32",
391
-      "action": "SCMP_ACT_ALLOW",
392
-      "args": []
393
-    },
394
-    {
395
-      "name": "getitimer",
396
-      "action": "SCMP_ACT_ALLOW",
397
-      "args": []
398
-    },
399
-    {
400
-      "name": "getpeername",
401
-      "action": "SCMP_ACT_ALLOW",
402
-      "args": []
403
-    },
404
-    {
405
-      "name": "getpgid",
406
-      "action": "SCMP_ACT_ALLOW",
407
-      "args": []
408
-    },
409
-    {
410
-      "name": "getpgrp",
411
-      "action": "SCMP_ACT_ALLOW",
412
-      "args": []
413
-    },
414
-    {
415
-      "name": "getpid",
416
-      "action": "SCMP_ACT_ALLOW",
417
-      "args": []
418
-    },
419
-    {
420
-      "name": "getppid",
421
-      "action": "SCMP_ACT_ALLOW",
422
-      "args": []
423
-    },
424
-    {
425
-      "name": "getpriority",
426
-      "action": "SCMP_ACT_ALLOW",
427
-      "args": []
428
-    },
429
-    {
430
-      "name": "getrandom",
431
-      "action": "SCMP_ACT_ALLOW",
432
-      "args": []
433
-    },
434
-    {
435
-      "name": "getresgid",
436
-      "action": "SCMP_ACT_ALLOW",
437
-      "args": []
438
-    },
439
-    {
440
-      "name": "getresgid32",
441
-      "action": "SCMP_ACT_ALLOW",
442
-      "args": []
443
-    },
444
-    {
445
-      "name": "getresuid",
446
-      "action": "SCMP_ACT_ALLOW",
447
-      "args": []
448
-    },
449
-    {
450
-      "name": "getresuid32",
451
-      "action": "SCMP_ACT_ALLOW",
452
-      "args": []
453
-    },
454
-    {
455
-      "name": "getrlimit",
456
-      "action": "SCMP_ACT_ALLOW",
457
-      "args": []
458
-    },
459
-    {
460
-      "name": "get_robust_list",
461
-      "action": "SCMP_ACT_ALLOW",
462
-      "args": []
463
-    },
464
-    {
465
-      "name": "getrusage",
466
-      "action": "SCMP_ACT_ALLOW",
467
-      "args": []
468
-    },
469
-    {
470
-      "name": "getsid",
471
-      "action": "SCMP_ACT_ALLOW",
472
-      "args": []
473
-    },
474
-    {
475
-      "name": "getsockname",
476
-      "action": "SCMP_ACT_ALLOW",
477
-      "args": []
478
-    },
479
-    {
480
-      "name": "getsockopt",
481
-      "action": "SCMP_ACT_ALLOW",
482
-      "args": []
483
-    },
484
-    {
485
-      "name": "get_thread_area",
486
-      "action": "SCMP_ACT_ALLOW",
487
-      "args": []
488
-    },
489
-    {
490
-      "name": "gettid",
491
-      "action": "SCMP_ACT_ALLOW",
492
-      "args": []
493
-    },
494
-    {
495
-      "name": "gettimeofday",
496
-      "action": "SCMP_ACT_ALLOW",
497
-      "args": []
498
-    },
499
-    {
500
-      "name": "getuid",
501
-      "action": "SCMP_ACT_ALLOW",
502
-      "args": []
503
-    },
504
-    {
505
-      "name": "getuid32",
506
-      "action": "SCMP_ACT_ALLOW",
507
-      "args": []
508
-    },
509
-    {
510
-      "name": "getxattr",
511
-      "action": "SCMP_ACT_ALLOW",
512
-      "args": []
513
-    },
514
-    {
515
-      "name": "inotify_add_watch",
516
-      "action": "SCMP_ACT_ALLOW",
517
-      "args": []
518
-    },
519
-    {
520
-      "name": "inotify_init",
521
-      "action": "SCMP_ACT_ALLOW",
522
-      "args": []
523
-    },
524
-    {
525
-      "name": "inotify_init1",
526
-      "action": "SCMP_ACT_ALLOW",
527
-      "args": []
528
-    },
529
-    {
530
-      "name": "inotify_rm_watch",
531
-      "action": "SCMP_ACT_ALLOW",
532
-      "args": []
533
-    },
534
-    {
535
-      "name": "io_cancel",
536
-      "action": "SCMP_ACT_ALLOW",
537
-      "args": []
538
-    },
539
-    {
540
-      "name": "ioctl",
541
-      "action": "SCMP_ACT_ALLOW",
542
-      "args": []
543
-    },
544
-    {
545
-      "name": "io_destroy",
546
-      "action": "SCMP_ACT_ALLOW",
547
-      "args": []
548
-    },
549
-    {
550
-      "name": "io_getevents",
551
-      "action": "SCMP_ACT_ALLOW",
552
-      "args": []
553
-    },
554
-    {
555
-      "name": "ioprio_get",
556
-      "action": "SCMP_ACT_ALLOW",
557
-      "args": []
558
-    },
559
-    {
560
-      "name": "ioprio_set",
561
-      "action": "SCMP_ACT_ALLOW",
562
-      "args": []
563
-    },
564
-    {
565
-      "name": "io_setup",
566
-      "action": "SCMP_ACT_ALLOW",
567
-      "args": []
568
-    },
569
-    {
570
-      "name": "io_submit",
571
-      "action": "SCMP_ACT_ALLOW",
572
-      "args": []
573
-    },
574
-    {
575
-      "name": "ipc",
576
-      "action": "SCMP_ACT_ALLOW",
577
-      "args": []
578
-    },
579
-    {
580
-      "name": "kill",
581
-      "action": "SCMP_ACT_ALLOW",
582
-      "args": []
583
-    },
584
-    {
585
-      "name": "lchown",
586
-      "action": "SCMP_ACT_ALLOW",
587
-      "args": []
588
-    },
589
-    {
590
-      "name": "lchown32",
591
-      "action": "SCMP_ACT_ALLOW",
592
-      "args": []
593
-    },
594
-    {
595
-      "name": "lgetxattr",
596
-      "action": "SCMP_ACT_ALLOW",
597
-      "args": []
598
-    },
599
-    {
600
-      "name": "link",
601
-      "action": "SCMP_ACT_ALLOW",
602
-      "args": []
603
-    },
604
-    {
605
-      "name": "linkat",
606
-      "action": "SCMP_ACT_ALLOW",
607
-      "args": []
608
-    },
609
-    {
610
-      "name": "listen",
611
-      "action": "SCMP_ACT_ALLOW",
612
-      "args": []
613
-    },
614
-    {
615
-      "name": "listxattr",
616
-      "action": "SCMP_ACT_ALLOW",
617
-      "args": []
618
-    },
619
-    {
620
-      "name": "llistxattr",
621
-      "action": "SCMP_ACT_ALLOW",
622
-      "args": []
623
-    },
624
-    {
625
-      "name": "_llseek",
626
-      "action": "SCMP_ACT_ALLOW",
627
-      "args": []
628
-    },
629
-    {
630
-      "name": "lremovexattr",
631
-      "action": "SCMP_ACT_ALLOW",
632
-      "args": []
633
-    },
634
-    {
635
-      "name": "lseek",
636
-      "action": "SCMP_ACT_ALLOW",
637
-      "args": []
638
-    },
639
-    {
640
-      "name": "lsetxattr",
641
-      "action": "SCMP_ACT_ALLOW",
642
-      "args": []
643
-    },
644
-    {
645
-      "name": "lstat",
646
-      "action": "SCMP_ACT_ALLOW",
647
-      "args": []
648
-    },
649
-    {
650
-      "name": "lstat64",
651
-      "action": "SCMP_ACT_ALLOW",
652
-      "args": []
653
-    },
654
-    {
655
-      "name": "madvise",
656
-      "action": "SCMP_ACT_ALLOW",
657
-      "args": []
658
-    },
659
-    {
660
-      "name": "memfd_create",
661
-      "action": "SCMP_ACT_ALLOW",
662
-      "args": []
663
-    },
664
-    {
665
-      "name": "mincore",
666
-      "action": "SCMP_ACT_ALLOW",
667
-      "args": []
668
-    },
669
-    {
670
-      "name": "mkdir",
671
-      "action": "SCMP_ACT_ALLOW",
672
-      "args": []
673
-    },
674
-    {
675
-      "name": "mkdirat",
676
-      "action": "SCMP_ACT_ALLOW",
677
-      "args": []
678
-    },
679
-    {
680
-      "name": "mknod",
681
-      "action": "SCMP_ACT_ALLOW",
682
-      "args": []
683
-    },
684
-    {
685
-      "name": "mknodat",
686
-      "action": "SCMP_ACT_ALLOW",
687
-      "args": []
688
-    },
689
-    {
690
-      "name": "mlock",
691
-      "action": "SCMP_ACT_ALLOW",
692
-      "args": []
693
-    },
694
-    {
695
-      "name": "mlock2",
696
-      "action": "SCMP_ACT_ALLOW",
697
-      "args": []
698
-    },
699
-    {
700
-      "name": "mlockall",
701
-      "action": "SCMP_ACT_ALLOW",
702
-      "args": []
703
-    },
704
-    {
705
-      "name": "mmap",
706
-      "action": "SCMP_ACT_ALLOW",
707
-      "args": []
708
-    },
709
-    {
710
-      "name": "mmap2",
711
-      "action": "SCMP_ACT_ALLOW",
712
-      "args": []
713
-    },
714
-    {
715
-      "name": "mprotect",
716
-      "action": "SCMP_ACT_ALLOW",
717
-      "args": []
718
-    },
719
-    {
720
-      "name": "mq_getsetattr",
721
-      "action": "SCMP_ACT_ALLOW",
722
-      "args": []
723
-    },
724
-    {
725
-      "name": "mq_notify",
726
-      "action": "SCMP_ACT_ALLOW",
727
-      "args": []
728
-    },
729
-    {
730
-      "name": "mq_open",
731
-      "action": "SCMP_ACT_ALLOW",
732
-      "args": []
733
-    },
734
-    {
735
-      "name": "mq_timedreceive",
736
-      "action": "SCMP_ACT_ALLOW",
737
-      "args": []
738
-    },
739
-    {
740
-      "name": "mq_timedsend",
741
-      "action": "SCMP_ACT_ALLOW",
742
-      "args": []
743
-    },
744
-    {
745
-      "name": "mq_unlink",
746
-      "action": "SCMP_ACT_ALLOW",
747
-      "args": []
748
-    },
749
-    {
750
-      "name": "mremap",
751
-      "action": "SCMP_ACT_ALLOW",
752
-      "args": []
753
-    },
754
-    {
755
-      "name": "msgctl",
756
-      "action": "SCMP_ACT_ALLOW",
757
-      "args": []
758
-    },
759
-    {
760
-      "name": "msgget",
761
-      "action": "SCMP_ACT_ALLOW",
762
-      "args": []
763
-    },
764
-    {
765
-      "name": "msgrcv",
766
-      "action": "SCMP_ACT_ALLOW",
767
-      "args": []
768
-    },
769
-    {
770
-      "name": "msgsnd",
771
-      "action": "SCMP_ACT_ALLOW",
772
-      "args": []
773
-    },
774
-    {
775
-      "name": "msync",
776
-      "action": "SCMP_ACT_ALLOW",
777
-      "args": []
778
-    },
779
-    {
780
-      "name": "munlock",
781
-      "action": "SCMP_ACT_ALLOW",
782
-      "args": []
783
-    },
784
-    {
785
-      "name": "munlockall",
786
-      "action": "SCMP_ACT_ALLOW",
787
-      "args": []
788
-    },
789
-    {
790
-      "name": "munmap",
791
-      "action": "SCMP_ACT_ALLOW",
792
-      "args": []
793
-    },
794
-    {
795
-      "name": "nanosleep",
796
-      "action": "SCMP_ACT_ALLOW",
797
-      "args": []
798
-    },
799
-    {
800
-      "name": "newfstatat",
801
-      "action": "SCMP_ACT_ALLOW",
802
-      "args": []
803
-    },
804
-    {
805
-      "name": "_newselect",
806
-      "action": "SCMP_ACT_ALLOW",
807
-      "args": []
808
-    },
809
-    {
810
-      "name": "open",
811
-      "action": "SCMP_ACT_ALLOW",
812
-      "args": []
813
-    },
814
-    {
815
-      "name": "openat",
816
-      "action": "SCMP_ACT_ALLOW",
817
-      "args": []
818
-    },
819
-    {
820
-      "name": "pause",
821
-      "action": "SCMP_ACT_ALLOW",
822
-      "args": []
823
-    },
824
-    {
825
-      "name": "personality",
826
-      "action": "SCMP_ACT_ALLOW",
827
-      "args": [
828
-        {
829
-          "index": 0,
830
-          "value": 0,
831
-          "valueTwo": 0,
832
-          "op": "SCMP_CMP_EQ"
833
-        }
834
-      ]
835
-    },
836
-    {
837
-      "name": "personality",
838
-      "action": "SCMP_ACT_ALLOW",
839
-      "args": [
840
-        {
841
-          "index": 0,
842
-          "value": 8,
843
-          "valueTwo": 0,
844
-          "op": "SCMP_CMP_EQ"
845
-        }
846
-      ]
847
-    },
848
-    {
849
-      "name": "personality",
850
-      "action": "SCMP_ACT_ALLOW",
851
-      "args": [
852
-        {
853
-          "index": 0,
854
-          "value": 4294967295,
855
-          "valueTwo": 0,
856
-          "op": "SCMP_CMP_EQ"
857
-        }
858
-      ]
859
-    },
860
-    {
861
-      "name": "pipe",
862
-      "action": "SCMP_ACT_ALLOW",
863
-      "args": []
864
-    },
865
-    {
866
-      "name": "pipe2",
867
-      "action": "SCMP_ACT_ALLOW",
868
-      "args": []
869
-    },
870
-    {
871
-      "name": "poll",
872
-      "action": "SCMP_ACT_ALLOW",
873
-      "args": []
874
-    },
875
-    {
876
-      "name": "ppoll",
877
-      "action": "SCMP_ACT_ALLOW",
878
-      "args": []
879
-    },
880
-    {
881
-      "name": "prctl",
882
-      "action": "SCMP_ACT_ALLOW",
883
-      "args": []
884
-    },
885
-    {
886
-      "name": "pread64",
887
-      "action": "SCMP_ACT_ALLOW",
888
-      "args": []
889
-    },
890
-    {
891
-      "name": "preadv",
892
-      "action": "SCMP_ACT_ALLOW",
893
-      "args": []
894
-    },
895
-    {
896
-      "name": "prlimit64",
897
-      "action": "SCMP_ACT_ALLOW",
898
-      "args": []
899
-    },
900
-    {
901
-      "name": "pselect6",
902
-      "action": "SCMP_ACT_ALLOW",
903
-      "args": []
904
-    },
905
-    {
906
-      "name": "pwrite64",
907
-      "action": "SCMP_ACT_ALLOW",
908
-      "args": []
909
-    },
910
-    {
911
-      "name": "pwritev",
912
-      "action": "SCMP_ACT_ALLOW",
913
-      "args": []
914
-    },
915
-    {
916
-      "name": "read",
917
-      "action": "SCMP_ACT_ALLOW",
918
-      "args": []
919
-    },
920
-    {
921
-      "name": "readahead",
922
-      "action": "SCMP_ACT_ALLOW",
923
-      "args": []
924
-    },
925
-    {
926
-      "name": "readlink",
927
-      "action": "SCMP_ACT_ALLOW",
928
-      "args": []
929
-    },
930
-    {
931
-      "name": "readlinkat",
932
-      "action": "SCMP_ACT_ALLOW",
933
-      "args": []
934
-    },
935
-    {
936
-      "name": "readv",
937
-      "action": "SCMP_ACT_ALLOW",
938
-      "args": []
939
-    },
940
-    {
941
-      "name": "recv",
942
-      "action": "SCMP_ACT_ALLOW",
943
-      "args": []
944
-    },
945
-    {
946
-      "name": "recvfrom",
947
-      "action": "SCMP_ACT_ALLOW",
948
-      "args": []
949
-    },
950
-    {
951
-      "name": "recvmmsg",
952
-      "action": "SCMP_ACT_ALLOW",
953
-      "args": []
954
-    },
955
-    {
956
-      "name": "recvmsg",
957
-      "action": "SCMP_ACT_ALLOW",
958
-      "args": []
959
-    },
960
-    {
961
-      "name": "remap_file_pages",
962
-      "action": "SCMP_ACT_ALLOW",
963
-      "args": []
964
-    },
965
-    {
966
-      "name": "removexattr",
967
-      "action": "SCMP_ACT_ALLOW",
968
-      "args": []
969
-    },
970
-    {
971
-      "name": "rename",
972
-      "action": "SCMP_ACT_ALLOW",
973
-      "args": []
974
-    },
975
-    {
976
-      "name": "renameat",
977
-      "action": "SCMP_ACT_ALLOW",
978
-      "args": []
979
-    },
980
-    {
981
-      "name": "renameat2",
982
-      "action": "SCMP_ACT_ALLOW",
983
-      "args": []
984
-    },
985
-    {
986
-      "name": "restart_syscall",
987
-      "action": "SCMP_ACT_ALLOW",
988
-      "args": []
989
-    },
990
-    {
991
-      "name": "rmdir",
992
-      "action": "SCMP_ACT_ALLOW",
993
-      "args": []
994
-    },
995
-    {
996
-      "name": "rt_sigaction",
997
-      "action": "SCMP_ACT_ALLOW",
998
-      "args": []
999
-    },
1000
-    {
1001
-      "name": "rt_sigpending",
1002
-      "action": "SCMP_ACT_ALLOW",
1003
-      "args": []
1004
-    },
1005
-    {
1006
-      "name": "rt_sigprocmask",
1007
-      "action": "SCMP_ACT_ALLOW",
1008
-      "args": []
1009
-    },
1010
-    {
1011
-      "name": "rt_sigqueueinfo",
1012
-      "action": "SCMP_ACT_ALLOW",
1013
-      "args": []
1014
-    },
1015
-    {
1016
-      "name": "rt_sigreturn",
1017
-      "action": "SCMP_ACT_ALLOW",
1018
-      "args": []
1019
-    },
1020
-    {
1021
-      "name": "rt_sigsuspend",
1022
-      "action": "SCMP_ACT_ALLOW",
1023
-      "args": []
1024
-    },
1025
-    {
1026
-      "name": "rt_sigtimedwait",
1027
-      "action": "SCMP_ACT_ALLOW",
1028
-      "args": []
1029
-    },
1030
-    {
1031
-      "name": "rt_tgsigqueueinfo",
1032
-      "action": "SCMP_ACT_ALLOW",
1033
-      "args": []
1034
-    },
1035
-    {
1036
-      "name": "sched_getaffinity",
1037
-      "action": "SCMP_ACT_ALLOW",
1038
-      "args": []
1039
-    },
1040
-    {
1041
-      "name": "sched_getattr",
1042
-      "action": "SCMP_ACT_ALLOW",
1043
-      "args": []
1044
-    },
1045
-    {
1046
-      "name": "sched_getparam",
1047
-      "action": "SCMP_ACT_ALLOW",
1048
-      "args": []
1049
-    },
1050
-    {
1051
-      "name": "sched_get_priority_max",
1052
-      "action": "SCMP_ACT_ALLOW",
1053
-      "args": []
1054
-    },
1055
-    {
1056
-      "name": "sched_get_priority_min",
1057
-      "action": "SCMP_ACT_ALLOW",
1058
-      "args": []
1059
-    },
1060
-    {
1061
-      "name": "sched_getscheduler",
1062
-      "action": "SCMP_ACT_ALLOW",
1063
-      "args": []
1064
-    },
1065
-    {
1066
-      "name": "sched_rr_get_interval",
1067
-      "action": "SCMP_ACT_ALLOW",
1068
-      "args": []
1069
-    },
1070
-    {
1071
-      "name": "sched_setaffinity",
1072
-      "action": "SCMP_ACT_ALLOW",
1073
-      "args": []
1074
-    },
1075
-    {
1076
-      "name": "sched_setattr",
1077
-      "action": "SCMP_ACT_ALLOW",
1078
-      "args": []
1079
-    },
1080
-    {
1081
-      "name": "sched_setparam",
1082
-      "action": "SCMP_ACT_ALLOW",
1083
-      "args": []
1084
-    },
1085
-    {
1086
-      "name": "sched_setscheduler",
1087
-      "action": "SCMP_ACT_ALLOW",
1088
-      "args": []
1089
-    },
1090
-    {
1091
-      "name": "sched_yield",
1092
-      "action": "SCMP_ACT_ALLOW",
1093
-      "args": []
1094
-    },
1095
-    {
1096
-      "name": "seccomp",
1097
-      "action": "SCMP_ACT_ALLOW",
1098
-      "args": []
1099
-    },
1100
-    {
1101
-      "name": "select",
1102
-      "action": "SCMP_ACT_ALLOW",
1103
-      "args": []
1104
-    },
1105
-    {
1106
-      "name": "semctl",
1107
-      "action": "SCMP_ACT_ALLOW",
1108
-      "args": []
1109
-    },
1110
-    {
1111
-      "name": "semget",
1112
-      "action": "SCMP_ACT_ALLOW",
1113
-      "args": []
1114
-    },
1115
-    {
1116
-      "name": "semop",
1117
-      "action": "SCMP_ACT_ALLOW",
1118
-      "args": []
1119
-    },
1120
-    {
1121
-      "name": "semtimedop",
1122
-      "action": "SCMP_ACT_ALLOW",
1123
-      "args": []
1124
-    },
1125
-    {
1126
-      "name": "send",
1127
-      "action": "SCMP_ACT_ALLOW",
1128
-      "args": []
1129
-    },
1130
-    {
1131
-      "name": "sendfile",
1132
-      "action": "SCMP_ACT_ALLOW",
1133
-      "args": []
1134
-    },
1135
-    {
1136
-      "name": "sendfile64",
1137
-      "action": "SCMP_ACT_ALLOW",
1138
-      "args": []
1139
-    },
1140
-    {
1141
-      "name": "sendmmsg",
1142
-      "action": "SCMP_ACT_ALLOW",
1143
-      "args": []
1144
-    },
1145
-    {
1146
-      "name": "sendmsg",
1147
-      "action": "SCMP_ACT_ALLOW",
1148
-      "args": []
1149
-    },
1150
-    {
1151
-      "name": "sendto",
1152
-      "action": "SCMP_ACT_ALLOW",
1153
-      "args": []
1154
-    },
1155
-    {
1156
-      "name": "setfsgid",
1157
-      "action": "SCMP_ACT_ALLOW",
1158
-      "args": []
1159
-    },
1160
-    {
1161
-      "name": "setfsgid32",
1162
-      "action": "SCMP_ACT_ALLOW",
1163
-      "args": []
1164
-    },
1165
-    {
1166
-      "name": "setfsuid",
1167
-      "action": "SCMP_ACT_ALLOW",
1168
-      "args": []
1169
-    },
1170
-    {
1171
-      "name": "setfsuid32",
1172
-      "action": "SCMP_ACT_ALLOW",
1173
-      "args": []
1174
-    },
1175
-    {
1176
-      "name": "setgid",
1177
-      "action": "SCMP_ACT_ALLOW",
1178
-      "args": []
1179
-    },
1180
-    {
1181
-      "name": "setgid32",
1182
-      "action": "SCMP_ACT_ALLOW",
1183
-      "args": []
1184
-    },
1185
-    {
1186
-      "name": "setgroups",
1187
-      "action": "SCMP_ACT_ALLOW",
1188
-      "args": []
1189
-    },
1190
-    {
1191
-      "name": "setgroups32",
1192
-      "action": "SCMP_ACT_ALLOW",
1193
-      "args": []
1194
-    },
1195
-    {
1196
-      "name": "setitimer",
1197
-      "action": "SCMP_ACT_ALLOW",
1198
-      "args": []
1199
-    },
1200
-    {
1201
-      "name": "setpgid",
1202
-      "action": "SCMP_ACT_ALLOW",
1203
-      "args": []
1204
-    },
1205
-    {
1206
-      "name": "setpriority",
1207
-      "action": "SCMP_ACT_ALLOW",
1208
-      "args": []
1209
-    },
1210
-    {
1211
-      "name": "setregid",
1212
-      "action": "SCMP_ACT_ALLOW",
1213
-      "args": []
1214
-    },
1215
-    {
1216
-      "name": "setregid32",
1217
-      "action": "SCMP_ACT_ALLOW",
1218
-      "args": []
1219
-    },
1220
-    {
1221
-      "name": "setresgid",
1222
-      "action": "SCMP_ACT_ALLOW",
1223
-      "args": []
1224
-    },
1225
-    {
1226
-      "name": "setresgid32",
1227
-      "action": "SCMP_ACT_ALLOW",
1228
-      "args": []
1229
-    },
1230
-    {
1231
-      "name": "setresuid",
1232
-      "action": "SCMP_ACT_ALLOW",
1233
-      "args": []
1234
-    },
1235
-    {
1236
-      "name": "setresuid32",
1237
-      "action": "SCMP_ACT_ALLOW",
1238
-      "args": []
1239
-    },
1240
-    {
1241
-      "name": "setreuid",
1242
-      "action": "SCMP_ACT_ALLOW",
1243
-      "args": []
1244
-    },
1245
-    {
1246
-      "name": "setreuid32",
1247
-      "action": "SCMP_ACT_ALLOW",
1248
-      "args": []
1249
-    },
1250
-    {
1251
-      "name": "setrlimit",
1252
-      "action": "SCMP_ACT_ALLOW",
1253
-      "args": []
1254
-    },
1255
-    {
1256
-      "name": "set_robust_list",
1257
-      "action": "SCMP_ACT_ALLOW",
1258
-      "args": []
1259
-    },
1260
-    {
1261
-      "name": "setsid",
1262
-      "action": "SCMP_ACT_ALLOW",
1263
-      "args": []
1264
-    },
1265
-    {
1266
-      "name": "setsockopt",
1267
-      "action": "SCMP_ACT_ALLOW",
1268
-      "args": []
1269
-    },
1270
-    {
1271
-      "name": "set_thread_area",
1272
-      "action": "SCMP_ACT_ALLOW",
1273
-      "args": []
1274
-    },
1275
-    {
1276
-      "name": "set_tid_address",
1277
-      "action": "SCMP_ACT_ALLOW",
1278
-      "args": []
1279
-    },
1280
-    {
1281
-      "name": "setuid",
1282
-      "action": "SCMP_ACT_ALLOW",
1283
-      "args": []
1284
-    },
1285
-    {
1286
-      "name": "setuid32",
1287
-      "action": "SCMP_ACT_ALLOW",
1288
-      "args": []
1289
-    },
1290
-    {
1291
-      "name": "setxattr",
1292
-      "action": "SCMP_ACT_ALLOW",
1293
-      "args": []
1294
-    },
1295
-    {
1296
-      "name": "shmat",
1297
-      "action": "SCMP_ACT_ALLOW",
1298
-      "args": []
1299
-    },
1300
-    {
1301
-      "name": "shmctl",
1302
-      "action": "SCMP_ACT_ALLOW",
1303
-      "args": []
1304
-    },
1305
-    {
1306
-      "name": "shmdt",
1307
-      "action": "SCMP_ACT_ALLOW",
1308
-      "args": []
1309
-    },
1310
-    {
1311
-      "name": "shmget",
1312
-      "action": "SCMP_ACT_ALLOW",
1313
-      "args": []
1314
-    },
1315
-    {
1316
-      "name": "shutdown",
1317
-      "action": "SCMP_ACT_ALLOW",
1318
-      "args": []
1319
-    },
1320
-    {
1321
-      "name": "sigaltstack",
1322
-      "action": "SCMP_ACT_ALLOW",
1323
-      "args": []
1324
-    },
1325
-    {
1326
-      "name": "signalfd",
1327
-      "action": "SCMP_ACT_ALLOW",
1328
-      "args": []
1329
-    },
1330
-    {
1331
-      "name": "signalfd4",
1332
-      "action": "SCMP_ACT_ALLOW",
1333
-      "args": []
1334
-    },
1335
-    {
1336
-      "name": "sigreturn",
1337
-      "action": "SCMP_ACT_ALLOW",
1338
-      "args": []
1339
-    },
1340
-    {
1341
-      "name": "socket",
1342
-      "action": "SCMP_ACT_ALLOW",
1343
-      "args": []
1344
-    },
1345
-    {
1346
-      "name": "socketcall",
1347
-      "action": "SCMP_ACT_ALLOW",
1348
-      "args": []
1349
-    },
1350
-    {
1351
-      "name": "socketpair",
1352
-      "action": "SCMP_ACT_ALLOW",
1353
-      "args": []
1354
-    },
1355
-    {
1356
-      "name": "splice",
1357
-      "action": "SCMP_ACT_ALLOW",
1358
-      "args": []
1359
-    },
1360
-    {
1361
-      "name": "stat",
1362
-      "action": "SCMP_ACT_ALLOW",
1363
-      "args": []
1364
-    },
1365
-    {
1366
-      "name": "stat64",
1367
-      "action": "SCMP_ACT_ALLOW",
1368
-      "args": []
1369
-    },
1370
-    {
1371
-      "name": "statfs",
1372
-      "action": "SCMP_ACT_ALLOW",
1373
-      "args": []
1374
-    },
1375
-    {
1376
-      "name": "statfs64",
1377
-      "action": "SCMP_ACT_ALLOW",
1378
-      "args": []
1379
-    },
1380
-    {
1381
-      "name": "symlink",
1382
-      "action": "SCMP_ACT_ALLOW",
1383
-      "args": []
1384
-    },
1385
-    {
1386
-      "name": "symlinkat",
1387
-      "action": "SCMP_ACT_ALLOW",
1388
-      "args": []
1389
-    },
1390
-    {
1391
-      "name": "sync",
1392
-      "action": "SCMP_ACT_ALLOW",
1393
-      "args": []
1394
-    },
1395
-    {
1396
-      "name": "sync_file_range",
1397
-      "action": "SCMP_ACT_ALLOW",
1398
-      "args": []
1399
-    },
1400
-    {
1401
-      "name": "syncfs",
1402
-      "action": "SCMP_ACT_ALLOW",
1403
-      "args": []
1404
-    },
1405
-    {
1406
-      "name": "sysinfo",
1407
-      "action": "SCMP_ACT_ALLOW",
1408
-      "args": []
1409
-    },
1410
-    {
1411
-      "name": "syslog",
1412
-      "action": "SCMP_ACT_ALLOW",
1413
-      "args": []
1414
-    },
1415
-    {
1416
-      "name": "tee",
1417
-      "action": "SCMP_ACT_ALLOW",
1418
-      "args": []
1419
-    },
1420
-    {
1421
-      "name": "tgkill",
1422
-      "action": "SCMP_ACT_ALLOW",
1423
-      "args": []
1424
-    },
1425
-    {
1426
-      "name": "time",
1427
-      "action": "SCMP_ACT_ALLOW",
1428
-      "args": []
1429
-    },
1430
-    {
1431
-      "name": "timer_create",
1432
-      "action": "SCMP_ACT_ALLOW",
1433
-      "args": []
1434
-    },
1435
-    {
1436
-      "name": "timer_delete",
1437
-      "action": "SCMP_ACT_ALLOW",
1438
-      "args": []
1439
-    },
1440
-    {
1441
-      "name": "timerfd_create",
1442
-      "action": "SCMP_ACT_ALLOW",
1443
-      "args": []
1444
-    },
1445
-    {
1446
-      "name": "timerfd_gettime",
1447
-      "action": "SCMP_ACT_ALLOW",
1448
-      "args": []
1449
-    },
1450
-    {
1451
-      "name": "timerfd_settime",
1452
-      "action": "SCMP_ACT_ALLOW",
1453
-      "args": []
1454
-    },
1455
-    {
1456
-      "name": "timer_getoverrun",
1457
-      "action": "SCMP_ACT_ALLOW",
1458
-      "args": []
1459
-    },
1460
-    {
1461
-      "name": "timer_gettime",
1462
-      "action": "SCMP_ACT_ALLOW",
1463
-      "args": []
1464
-    },
1465
-    {
1466
-      "name": "timer_settime",
1467
-      "action": "SCMP_ACT_ALLOW",
1468
-      "args": []
1469
-    },
1470
-    {
1471
-      "name": "times",
1472
-      "action": "SCMP_ACT_ALLOW",
1473
-      "args": []
1474
-    },
1475
-    {
1476
-      "name": "tkill",
1477
-      "action": "SCMP_ACT_ALLOW",
1478
-      "args": []
1479
-    },
1480
-    {
1481
-      "name": "truncate",
1482
-      "action": "SCMP_ACT_ALLOW",
1483
-      "args": []
1484
-    },
1485
-    {
1486
-      "name": "truncate64",
1487
-      "action": "SCMP_ACT_ALLOW",
1488
-      "args": []
1489
-    },
1490
-    {
1491
-      "name": "ugetrlimit",
1492
-      "action": "SCMP_ACT_ALLOW",
1493
-      "args": []
1494
-    },
1495
-    {
1496
-      "name": "umask",
1497
-      "action": "SCMP_ACT_ALLOW",
1498
-      "args": []
1499
-    },
1500
-    {
1501
-      "name": "uname",
1502
-      "action": "SCMP_ACT_ALLOW",
1503
-      "args": []
1504
-    },
1505
-    {
1506
-      "name": "unlink",
1507
-      "action": "SCMP_ACT_ALLOW",
1508
-      "args": []
1509
-    },
1510
-    {
1511
-      "name": "unlinkat",
1512
-      "action": "SCMP_ACT_ALLOW",
1513
-      "args": []
1514
-    },
1515
-    {
1516
-      "name": "utime",
1517
-      "action": "SCMP_ACT_ALLOW",
1518
-      "args": []
1519
-    },
1520
-    {
1521
-      "name": "utimensat",
1522
-      "action": "SCMP_ACT_ALLOW",
1523
-      "args": []
1524
-    },
1525
-    {
1526
-      "name": "utimes",
1527
-      "action": "SCMP_ACT_ALLOW",
1528
-      "args": []
1529
-    },
1530
-    {
1531
-      "name": "vfork",
1532
-      "action": "SCMP_ACT_ALLOW",
1533
-      "args": []
1534
-    },
1535
-    {
1536
-      "name": "vmsplice",
1537
-      "action": "SCMP_ACT_ALLOW",
1538
-      "args": []
1539
-    },
1540
-    {
1541
-      "name": "wait4",
1542
-      "action": "SCMP_ACT_ALLOW",
1543
-      "args": []
1544
-    },
1545
-    {
1546
-      "name": "waitid",
1547
-      "action": "SCMP_ACT_ALLOW",
1548
-      "args": []
1549
-    },
1550
-    {
1551
-      "name": "waitpid",
1552
-      "action": "SCMP_ACT_ALLOW",
1553
-      "args": []
1554
-    },
1555
-    {
1556
-      "name": "write",
1557
-      "action": "SCMP_ACT_ALLOW",
1558
-      "args": []
1559
-    },
1560
-    {
1561
-      "name": "writev",
1562
-      "action": "SCMP_ACT_ALLOW",
1563
-      "args": []
1564
-    },
1565
-    {
1566
-      "name": "arch_prctl",
1567
-      "action": "SCMP_ACT_ALLOW",
1568
-      "args": []
1569
-    },
1570
-    {
1571
-      "name": "modify_ldt",
1572
-      "action": "SCMP_ACT_ALLOW",
1573
-      "args": []
1574
-    },
1575
-    {
1576
-      "name": "chroot",
1577
-      "action": "SCMP_ACT_ALLOW",
1578
-      "args": []
1579
-    },
1580
-    {
1581
-      "name": "clone",
1582
-      "action": "SCMP_ACT_ALLOW",
1583
-      "args": [
1584
-        {
1585
-          "index": 0,
1586
-          "value": 2080505856,
1587
-          "valueTwo": 0,
1588
-          "op": "SCMP_CMP_MASKED_EQ"
1589
-        }
1590
-      ]
1591
-    }
1592
-  ]
1593
-}
1594 1
\ No newline at end of file
1595 2
deleted file mode 100644
... ...
@@ -1,34 +0,0 @@
1
-{
2
-    "defaultAction": "SCMP_ACT_ERRNO",
3
-    "defaultErrnoRet": 1,
4
-    "syscalls": [
5
-        {
6
-            "name": "clone",
7
-            "action": "SCMP_ACT_ALLOW",
8
-            "args": [
9
-                {
10
-                    "index": 0,
11
-                    "value": 2114060288,
12
-                    "valueTwo": 0,
13
-                    "op": "SCMP_CMP_MASKED_EQ"
14
-                }
15
-            ]
16
-        },
17
-        {
18
-            "name": "open",
19
-            "action": "SCMP_ACT_ALLOW",
20
-            "args": []
21
-        },
22
-        {
23
-            "name": "close",
24
-            "action": "SCMP_ACT_ALLOW",
25
-            "args": []
26
-        },
27
-        {
28
-            "name": "syslog",
29
-            "action": "SCMP_ACT_ERRNO",
30
-            "errnoRet": 12345,
31
-            "args": []
32
-        }
33
-    ]
34
-}
35 1
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-//go:build ignore
2
-
3
-package main
4
-
5
-import (
6
-	"encoding/json"
7
-	"os"
8
-	"path/filepath"
9
-
10
-	"github.com/docker/docker/profiles/seccomp"
11
-)
12
-
13
-// saves the default seccomp profile as a json file so people can use it as a
14
-// base for their own custom profiles
15
-func main() {
16
-	wd, err := os.Getwd()
17
-	if err != nil {
18
-		panic(err)
19
-	}
20
-	f := filepath.Join(wd, "default.json")
21
-
22
-	// write the default profile to the file
23
-	b, err := json.MarshalIndent(seccomp.DefaultProfile(), "", "\t")
24
-	if err != nil {
25
-		panic(err)
26
-	}
27
-
28
-	if err := os.WriteFile(f, b, 0o644); err != nil {
29
-		panic(err)
30
-	}
31
-}
32 1
deleted file mode 100644
... ...
@@ -1,58 +0,0 @@
1
-package seccomp
2
-
3
-import (
4
-	"fmt"
5
-	"sync"
6
-
7
-	"golang.org/x/sys/unix"
8
-)
9
-
10
-var (
11
-	currentKernelVersion *KernelVersion
12
-	kernelVersionError   error
13
-	once                 sync.Once
14
-)
15
-
16
-// getKernelVersion gets the current kernel version.
17
-func getKernelVersion() (*KernelVersion, error) {
18
-	once.Do(func() {
19
-		var uts unix.Utsname
20
-		if err := unix.Uname(&uts); err != nil {
21
-			return
22
-		}
23
-		// Remove the \x00 from the release for Atoi to parse correctly
24
-		currentKernelVersion, kernelVersionError = parseRelease(unix.ByteSliceToString(uts.Release[:]))
25
-	})
26
-	return currentKernelVersion, kernelVersionError
27
-}
28
-
29
-// parseRelease parses a string and creates a KernelVersion based on it.
30
-func parseRelease(release string) (*KernelVersion, error) {
31
-	version := KernelVersion{}
32
-
33
-	// We're only make sure we get the "kernel" and "major revision". Sometimes we have
34
-	// 3.12.25-gentoo, but sometimes we just have 3.12-1-amd64.
35
-	_, err := fmt.Sscanf(release, "%d.%d", &version.Kernel, &version.Major)
36
-	if err != nil {
37
-		return nil, fmt.Errorf("failed to parse kernel version %q: %w", release, err)
38
-	}
39
-	return &version, nil
40
-}
41
-
42
-// kernelGreaterEqualThan checks if the host's kernel version is greater than, or
43
-// equal to the given kernel version v. Only "kernel version" and "major revision"
44
-// can be specified (e.g., "3.12") and will be taken into account, which means
45
-// that 3.12.25-gentoo and 3.12-1-amd64 are considered equal (kernel: 3, major: 12).
46
-func kernelGreaterEqualThan(minVersion KernelVersion) (bool, error) {
47
-	kv, err := getKernelVersion()
48
-	if err != nil {
49
-		return false, err
50
-	}
51
-	if kv.Kernel > minVersion.Kernel {
52
-		return true, nil
53
-	}
54
-	if kv.Kernel == minVersion.Kernel && kv.Major >= minVersion.Major {
55
-		return true, nil
56
-	}
57
-	return false, nil
58
-}
59 1
deleted file mode 100644
... ...
@@ -1,120 +0,0 @@
1
-package seccomp
2
-
3
-import (
4
-	"errors"
5
-	"testing"
6
-)
7
-
8
-func TestGetKernelVersion(t *testing.T) {
9
-	version, err := getKernelVersion()
10
-	if err != nil {
11
-		t.Fatal(err)
12
-	}
13
-	if version == nil {
14
-		t.Fatal("version is nil")
15
-	}
16
-	if version.Kernel == 0 {
17
-		t.Fatal("no kernel version")
18
-	}
19
-}
20
-
21
-// TestParseRelease tests the ParseRelease() function
22
-func TestParseRelease(t *testing.T) {
23
-	tests := []struct {
24
-		in          string
25
-		out         KernelVersion
26
-		expectedErr error
27
-	}{
28
-		{in: "3.8", out: KernelVersion{Kernel: 3, Major: 8}},
29
-		{in: "3.8.0", out: KernelVersion{Kernel: 3, Major: 8}},
30
-		{in: "3.8.0-19-generic", out: KernelVersion{Kernel: 3, Major: 8}},
31
-		{in: "3.4.54.longterm-1", out: KernelVersion{Kernel: 3, Major: 4}},
32
-		{in: "3.10.0-862.2.3.el7.x86_64", out: KernelVersion{Kernel: 3, Major: 10}},
33
-		{in: "3.12.8tag", out: KernelVersion{Kernel: 3, Major: 12}},
34
-		{in: "3.12-1-amd64", out: KernelVersion{Kernel: 3, Major: 12}},
35
-		{in: "3.12foobar", out: KernelVersion{Kernel: 3, Major: 12}},
36
-		{in: "99.999.999-19-generic", out: KernelVersion{Kernel: 99, Major: 999}},
37
-		{in: "", expectedErr: errors.New(`failed to parse kernel version "": EOF`)},
38
-		{in: "3", expectedErr: errors.New(`failed to parse kernel version "3": unexpected EOF`)},
39
-		{in: "3.", expectedErr: errors.New(`failed to parse kernel version "3.": EOF`)},
40
-		{in: "3a", expectedErr: errors.New(`failed to parse kernel version "3a": input does not match format`)},
41
-		{in: "3.a", expectedErr: errors.New(`failed to parse kernel version "3.a": expected integer`)},
42
-		{in: "a", expectedErr: errors.New(`failed to parse kernel version "a": expected integer`)},
43
-		{in: "a.a", expectedErr: errors.New(`failed to parse kernel version "a.a": expected integer`)},
44
-		{in: "a.a.a-a", expectedErr: errors.New(`failed to parse kernel version "a.a.a-a": expected integer`)},
45
-		{in: "-3", expectedErr: errors.New(`failed to parse kernel version "-3": expected integer`)},
46
-		{in: "-3.", expectedErr: errors.New(`failed to parse kernel version "-3.": expected integer`)},
47
-		{in: "-3.8", expectedErr: errors.New(`failed to parse kernel version "-3.8": expected integer`)},
48
-		{in: "-3.-8", expectedErr: errors.New(`failed to parse kernel version "-3.-8": expected integer`)},
49
-		{in: "3.-8", expectedErr: errors.New(`failed to parse kernel version "3.-8": expected integer`)},
50
-	}
51
-	for _, tc := range tests {
52
-		t.Run(tc.in, func(t *testing.T) {
53
-			version, err := parseRelease(tc.in)
54
-			if tc.expectedErr != nil {
55
-				if err == nil {
56
-					t.Fatal("expected an error")
57
-				}
58
-				if err.Error() != tc.expectedErr.Error() {
59
-					t.Fatalf("expected: %s, got: %s", tc.expectedErr, err)
60
-				}
61
-				return
62
-			}
63
-			if err != nil {
64
-				t.Fatal("unexpected error:", err)
65
-			}
66
-			if version == nil {
67
-				t.Fatal("version is nil")
68
-			}
69
-			if version.Kernel != tc.out.Kernel || version.Major != tc.out.Major {
70
-				t.Fatalf("expected: %d.%d, got: %d.%d", tc.out.Kernel, tc.out.Major, version.Kernel, version.Major)
71
-			}
72
-		})
73
-	}
74
-}
75
-
76
-func TestKernelGreaterEqualThan(t *testing.T) {
77
-	// Get the current kernel version, so that we can make test relative to that
78
-	v, err := getKernelVersion()
79
-	if err != nil {
80
-		t.Fatal(err)
81
-	}
82
-
83
-	tests := []struct {
84
-		doc      string
85
-		in       KernelVersion
86
-		expected bool
87
-	}{
88
-		{
89
-			doc:      "same version",
90
-			in:       KernelVersion{v.Kernel, v.Major},
91
-			expected: true,
92
-		},
93
-		{
94
-			doc:      "kernel minus one",
95
-			in:       KernelVersion{v.Kernel - 1, v.Major},
96
-			expected: true,
97
-		},
98
-		{
99
-			doc:      "kernel plus one",
100
-			in:       KernelVersion{v.Kernel + 1, v.Major},
101
-			expected: false,
102
-		},
103
-		{
104
-			doc:      "major plus one",
105
-			in:       KernelVersion{v.Kernel, v.Major + 1},
106
-			expected: false,
107
-		},
108
-	}
109
-	for _, tc := range tests {
110
-		t.Run(tc.doc+": "+tc.in.String(), func(t *testing.T) {
111
-			ok, err := kernelGreaterEqualThan(tc.in)
112
-			if err != nil {
113
-				t.Fatal("unexpected error:", err)
114
-			}
115
-			if ok != tc.expected {
116
-				t.Fatalf("expected: %v, got: %v", tc.expected, ok)
117
-			}
118
-		})
119
-	}
120
-}
121 1
deleted file mode 100644
... ...
@@ -1,115 +0,0 @@
1
-package seccomp
2
-
3
-import (
4
-	"encoding/json"
5
-	"fmt"
6
-	"strconv"
7
-	"strings"
8
-
9
-	"github.com/opencontainers/runtime-spec/specs-go"
10
-)
11
-
12
-// Seccomp represents the config for a seccomp profile for syscall restriction.
13
-// It is used to marshal/unmarshal the JSON profiles as accepted by docker, and
14
-// extends the runtime-spec's specs.LinuxSeccomp, overriding some fields to
15
-// provide the ability to define conditional rules based on the host's kernel
16
-// version, architecture, and the container's capabilities.
17
-type Seccomp struct {
18
-	specs.LinuxSeccomp
19
-
20
-	// ArchMap contains a list of Architectures and Sub-architectures for the
21
-	// profile. When generating the profile, this list is expanded to a
22
-	// []specs.Arch, to propagate the Architectures field of the profile.
23
-	ArchMap []Architecture `json:"archMap,omitempty"`
24
-
25
-	// Syscalls contains lists of syscall rules. Rules can define conditions
26
-	// for them to be included or excluded in the resulting profile (based on
27
-	// kernel version, architecture, capabilities, etc.). These lists are
28
-	// expanded to an specs.Syscall  When generating the profile, these lists
29
-	// are expanded to a []specs.LinuxSyscall.
30
-	Syscalls []*Syscall `json:"syscalls"`
31
-}
32
-
33
-// Architecture is used to represent a specific architecture
34
-// and its sub-architectures
35
-type Architecture struct {
36
-	Arch      specs.Arch   `json:"architecture"`
37
-	SubArches []specs.Arch `json:"subArchitectures"`
38
-}
39
-
40
-// Filter is used to conditionally apply Seccomp rules
41
-type Filter struct {
42
-	Caps   []string `json:"caps,omitempty"`
43
-	Arches []string `json:"arches,omitempty"`
44
-
45
-	// MinKernel describes the minimum kernel version the rule must be applied
46
-	// on, in the format "<kernel version>.<major revision>" (e.g. "3.12").
47
-	//
48
-	// When matching the kernel version of the host, minor revisions, and distro-
49
-	// specific suffixes are ignored, which means that "3.12.25-gentoo", "3.12-1-amd64",
50
-	// "3.12", and "3.12-rc5" are considered equal (kernel 3, major revision 12).
51
-	MinKernel *KernelVersion `json:"minKernel,omitempty"`
52
-}
53
-
54
-// Syscall is used to match a group of syscalls in Seccomp. It extends the
55
-// runtime-spec Syscall type, adding a "Name" field for backward compatibility
56
-// with older JSON representations, additional "Comment" metadata, and conditional
57
-// rules ("Includes", "Excludes") used to generate a runtime-spec Seccomp profile
58
-// based on the container (capabilities) and host's (arch, kernel) configuration.
59
-type Syscall struct {
60
-	specs.LinuxSyscall
61
-	// Deprecated: kept for backward compatibility with old JSON profiles, use Names instead
62
-	Name     string  `json:"name,omitempty"`
63
-	Comment  string  `json:"comment,omitempty"`
64
-	Includes *Filter `json:"includes,omitempty"`
65
-	Excludes *Filter `json:"excludes,omitempty"`
66
-}
67
-
68
-// KernelVersion holds information about the kernel.
69
-type KernelVersion struct {
70
-	Kernel uint64 // Version of the Kernel (i.e., the "4" in "4.1.2-generic")
71
-	Major  uint64 // Major revision of the Kernel (i.e., the "1" in "4.1.2-generic")
72
-}
73
-
74
-// String implements fmt.Stringer for KernelVersion
75
-func (k *KernelVersion) String() string {
76
-	if k.Kernel > 0 || k.Major > 0 {
77
-		return fmt.Sprintf("%d.%d", k.Kernel, k.Major)
78
-	}
79
-	return ""
80
-}
81
-
82
-// MarshalJSON implements json.Unmarshaler for KernelVersion
83
-func (k *KernelVersion) MarshalJSON() ([]byte, error) {
84
-	return json.Marshal(k.String())
85
-}
86
-
87
-// UnmarshalJSON implements json.Marshaler for KernelVersion
88
-func (k *KernelVersion) UnmarshalJSON(version []byte) error {
89
-	var (
90
-		ver string
91
-		err error
92
-	)
93
-
94
-	// make sure we have a string
95
-	if err = json.Unmarshal(version, &ver); err != nil {
96
-		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": %v`, string(version), err)
97
-	}
98
-	if ver == "" {
99
-		return nil
100
-	}
101
-	parts := strings.SplitN(ver, ".", 3)
102
-	if len(parts) != 2 {
103
-		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>"`, string(version))
104
-	}
105
-	if k.Kernel, err = strconv.ParseUint(parts[0], 10, 8); err != nil {
106
-		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": %v`, string(version), err)
107
-	}
108
-	if k.Major, err = strconv.ParseUint(parts[1], 10, 8); err != nil {
109
-		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": %v`, string(version), err)
110
-	}
111
-	if k.Kernel == 0 && k.Major == 0 {
112
-		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": version cannot be 0.0`, string(version))
113
-	}
114
-	return nil
115
-}
116 1
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+package seccomp
1
+
2
+import "github.com/moby/profiles/seccomp"
3
+
4
+// Seccomp represents the config for a seccomp profile for syscall restriction.
5
+// It is used to marshal/unmarshal the JSON profiles as accepted by docker, and
6
+// extends the runtime-spec's specs.LinuxSeccomp, overriding some fields to
7
+// provide the ability to define conditional rules based on the host's kernel
8
+// version, architecture, and the container's capabilities.
9
+//
10
+// Deprecated: use [seccomp.Seccomp].
11
+type Seccomp = seccomp.Seccomp
12
+
13
+// Architecture is used to represent a specific architecture
14
+// and its sub-architectures
15
+//
16
+// Deprecated: use [seccomp.Architecture].
17
+type Architecture = seccomp.Architecture
18
+
19
+// Filter is used to conditionally apply Seccomp rules
20
+//
21
+// Deprecated: use [seccomp.Filter].
22
+type Filter = seccomp.Filter
23
+
24
+// Syscall is used to match a group of syscalls in Seccomp. It extends the
25
+// runtime-spec Syscall type, adding a "Name" field for backward compatibility
26
+// with older JSON representations, additional "Comment" metadata, and conditional
27
+// rules ("Includes", "Excludes") used to generate a runtime-spec Seccomp profile
28
+// based on the container (capabilities) and host's (arch, kernel) configuration.
29
+//
30
+// Deprecated: use [seccomp.Syscall].
31
+type Syscall = seccomp.Syscall
32
+
33
+// KernelVersion holds information about the kernel.
34
+//
35
+// Deprecated: use [seccomp.KernelVersion].
36
+type KernelVersion = seccomp.KernelVersion
0 37
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+package seccomp
1
+
2
+import (
3
+	"github.com/moby/profiles/seccomp"
4
+	"github.com/opencontainers/runtime-spec/specs-go"
5
+)
6
+
7
+// DefaultProfile defines the allowed syscalls for the default seccomp profile.
8
+//
9
+// Deprecated: use [seccomp.DefaultProfile].
10
+func DefaultProfile() *seccomp.Seccomp {
11
+	return seccomp.DefaultProfile()
12
+}
13
+
14
+// GetDefaultProfile returns the default seccomp profile.
15
+//
16
+// Deprecated: use [seccomp.GetDefaultProfile].
17
+func GetDefaultProfile(rs *specs.Spec) (*specs.LinuxSeccomp, error) {
18
+	return seccomp.GetDefaultProfile(rs)
19
+}
20
+
21
+// LoadProfile takes a json string and decodes the seccomp profile.
22
+//
23
+// Deprecated: use [seccomp.LoadProfile].
24
+func LoadProfile(body string, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
25
+	return seccomp.LoadProfile(body, rs)
26
+}
0 27
deleted file mode 100644
... ...
@@ -1,168 +0,0 @@
1
-//go:generate go run -tags 'seccomp' generate.go
2
-
3
-package seccomp
4
-
5
-import (
6
-	"encoding/json"
7
-	"errors"
8
-	"fmt"
9
-	"runtime"
10
-
11
-	"github.com/opencontainers/runtime-spec/specs-go"
12
-)
13
-
14
-// GetDefaultProfile returns the default seccomp profile.
15
-func GetDefaultProfile(rs *specs.Spec) (*specs.LinuxSeccomp, error) {
16
-	return setupSeccomp(DefaultProfile(), rs)
17
-}
18
-
19
-// LoadProfile takes a json string and decodes the seccomp profile.
20
-func LoadProfile(body string, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
21
-	var config Seccomp
22
-	if err := json.Unmarshal([]byte(body), &config); err != nil {
23
-		return nil, fmt.Errorf("Decoding seccomp profile failed: %v", err)
24
-	}
25
-	return setupSeccomp(&config, rs)
26
-}
27
-
28
-// libseccomp string => seccomp arch
29
-var nativeToSeccomp = map[string]specs.Arch{
30
-	"x86":         specs.ArchX86,
31
-	"amd64":       specs.ArchX86_64,
32
-	"arm":         specs.ArchARM,
33
-	"arm64":       specs.ArchAARCH64,
34
-	"mips64":      specs.ArchMIPS64,
35
-	"mips64n32":   specs.ArchMIPS64N32,
36
-	"mipsel64":    specs.ArchMIPSEL64,
37
-	"mips3l64n32": specs.ArchMIPSEL64N32,
38
-	"mipsle":      specs.ArchMIPSEL,
39
-	"ppc":         specs.ArchPPC,
40
-	"ppc64":       specs.ArchPPC64,
41
-	"ppc64le":     specs.ArchPPC64LE,
42
-	"riscv64":     specs.ArchRISCV64,
43
-	"s390":        specs.ArchS390,
44
-	"s390x":       specs.ArchS390X,
45
-}
46
-
47
-// GOARCH => libseccomp string
48
-var goToNative = map[string]string{
49
-	"386":         "x86",
50
-	"amd64":       "amd64",
51
-	"arm":         "arm",
52
-	"arm64":       "arm64",
53
-	"mips64":      "mips64",
54
-	"mips64p32":   "mips64n32",
55
-	"mips64le":    "mipsel64",
56
-	"mips64p32le": "mips3l64n32",
57
-	"mipsle":      "mipsel",
58
-	"ppc":         "ppc",
59
-	"ppc64":       "ppc64",
60
-	"ppc64le":     "ppc64le",
61
-	"riscv64":     "riscv64",
62
-	"s390":        "s390",
63
-	"s390x":       "s390x",
64
-}
65
-
66
-// inSlice tests whether a string is contained in a slice of strings or not.
67
-// Comparison is case sensitive
68
-func inSlice(slice []string, s string) bool {
69
-	for _, ss := range slice {
70
-		if s == ss {
71
-			return true
72
-		}
73
-	}
74
-	return false
75
-}
76
-
77
-func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
78
-	if config == nil {
79
-		return nil, nil
80
-	}
81
-
82
-	// No default action specified, no syscalls listed, assume seccomp disabled
83
-	if config.DefaultAction == "" && len(config.Syscalls) == 0 {
84
-		return nil, nil
85
-	}
86
-
87
-	if len(config.Architectures) != 0 && len(config.ArchMap) != 0 {
88
-		return nil, errors.New("both 'architectures' and 'archMap' are specified in the seccomp profile, use either 'architectures' or 'archMap'")
89
-	}
90
-
91
-	if len(config.LinuxSeccomp.Syscalls) != 0 {
92
-		// The Seccomp type overrides the LinuxSeccomp.Syscalls field,
93
-		// so 'this should never happen' when loaded from JSON, but could
94
-		// happen if someone constructs the Config from source.
95
-		return nil, errors.New("the LinuxSeccomp.Syscalls field should be empty")
96
-	}
97
-
98
-	var (
99
-		// Copy all common / standard properties to the output profile
100
-		newConfig = &config.LinuxSeccomp
101
-		arch      = goToNative[runtime.GOARCH]
102
-	)
103
-	if seccompArch, ok := nativeToSeccomp[arch]; ok {
104
-		for _, a := range config.ArchMap {
105
-			if a.Arch == seccompArch {
106
-				newConfig.Architectures = append(newConfig.Architectures, a.Arch)
107
-				newConfig.Architectures = append(newConfig.Architectures, a.SubArches...)
108
-				break
109
-			}
110
-		}
111
-	}
112
-
113
-Loop:
114
-	// Convert Syscall to OCI runtimes-spec specs.LinuxSyscall after filtering them.
115
-	for _, call := range config.Syscalls {
116
-		if call.Name != "" {
117
-			if len(call.Names) != 0 {
118
-				return nil, errors.New("both 'name' and 'names' are specified in the seccomp profile, use either 'name' or 'names'")
119
-			}
120
-			call.Names = []string{call.Name}
121
-		}
122
-		if call.Excludes != nil {
123
-			if len(call.Excludes.Arches) > 0 {
124
-				if inSlice(call.Excludes.Arches, arch) {
125
-					continue Loop
126
-				}
127
-			}
128
-			if len(call.Excludes.Caps) > 0 {
129
-				for _, c := range call.Excludes.Caps {
130
-					if inSlice(rs.Process.Capabilities.Bounding, c) {
131
-						continue Loop
132
-					}
133
-				}
134
-			}
135
-			if call.Excludes.MinKernel != nil {
136
-				if ok, err := kernelGreaterEqualThan(*call.Excludes.MinKernel); err != nil {
137
-					return nil, err
138
-				} else if ok {
139
-					continue Loop
140
-				}
141
-			}
142
-		}
143
-		if call.Includes != nil {
144
-			if len(call.Includes.Arches) > 0 {
145
-				if !inSlice(call.Includes.Arches, arch) {
146
-					continue Loop
147
-				}
148
-			}
149
-			if len(call.Includes.Caps) > 0 {
150
-				for _, c := range call.Includes.Caps {
151
-					if !inSlice(rs.Process.Capabilities.Bounding, c) {
152
-						continue Loop
153
-					}
154
-				}
155
-			}
156
-			if call.Includes.MinKernel != nil {
157
-				if ok, err := kernelGreaterEqualThan(*call.Includes.MinKernel); err != nil {
158
-					return nil, err
159
-				} else if !ok {
160
-					continue Loop
161
-				}
162
-			}
163
-		}
164
-		newConfig.Syscalls = append(newConfig.Syscalls, call.LinuxSyscall)
165
-	}
166
-
167
-	return newConfig, nil
168
-}
169 1
deleted file mode 100644
... ...
@@ -1,314 +0,0 @@
1
-//go:build linux
2
-
3
-package seccomp
4
-
5
-import (
6
-	"encoding/json"
7
-	"os"
8
-	"reflect"
9
-	"strings"
10
-	"testing"
11
-
12
-	"github.com/opencontainers/runtime-spec/specs-go"
13
-)
14
-
15
-func assertDeepEqual(t *testing.T, expected interface{}, actual interface{}) {
16
-	t.Helper()
17
-	if !reflect.DeepEqual(expected, actual) {
18
-		t.Fatalf("\nexpected: %+#v\ngot     : %+#v", expected, actual)
19
-	}
20
-}
21
-
22
-func TestLoadProfile(t *testing.T) {
23
-	f, err := os.ReadFile("fixtures/example.json")
24
-	if err != nil {
25
-		t.Fatal(err)
26
-	}
27
-	rs := createSpec()
28
-	p, err := LoadProfile(string(f), &rs)
29
-	if err != nil {
30
-		t.Fatal(err)
31
-	}
32
-	var expectedErrno uint = 12345
33
-	var expectedDefaultErrno uint = 1
34
-	expected := specs.LinuxSeccomp{
35
-		DefaultAction:   specs.ActErrno,
36
-		DefaultErrnoRet: &expectedDefaultErrno,
37
-		Syscalls: []specs.LinuxSyscall{
38
-			{
39
-				Names:  []string{"clone"},
40
-				Action: specs.ActAllow,
41
-				Args: []specs.LinuxSeccompArg{{
42
-					Index:    0,
43
-					Value:    2114060288,
44
-					ValueTwo: 0,
45
-					Op:       specs.OpMaskedEqual,
46
-				}},
47
-			},
48
-			{
49
-				Names:  []string{"open"},
50
-				Action: specs.ActAllow,
51
-				Args:   []specs.LinuxSeccompArg{},
52
-			},
53
-			{
54
-				Names:  []string{"close"},
55
-				Action: specs.ActAllow,
56
-				Args:   []specs.LinuxSeccompArg{},
57
-			},
58
-			{
59
-				Names:    []string{"syslog"},
60
-				Action:   specs.ActErrno,
61
-				ErrnoRet: &expectedErrno,
62
-				Args:     []specs.LinuxSeccompArg{},
63
-			},
64
-		},
65
-	}
66
-
67
-	assertDeepEqual(t, expected, *p)
68
-}
69
-
70
-func TestLoadProfileWithDefaultErrnoRet(t *testing.T) {
71
-	profile := []byte(`{
72
-"defaultAction": "SCMP_ACT_ERRNO",
73
-"defaultErrnoRet": 6
74
-}`)
75
-	rs := createSpec()
76
-	p, err := LoadProfile(string(profile), &rs)
77
-	if err != nil {
78
-		t.Fatal(err)
79
-	}
80
-
81
-	expectedErrnoRet := uint(6)
82
-	expected := specs.LinuxSeccomp{
83
-		DefaultAction:   specs.ActErrno,
84
-		DefaultErrnoRet: &expectedErrnoRet,
85
-	}
86
-
87
-	assertDeepEqual(t, expected, *p)
88
-}
89
-
90
-func TestLoadProfileWithListenerPath(t *testing.T) {
91
-	profile := []byte(`{
92
-"defaultAction": "SCMP_ACT_ERRNO",
93
-"listenerPath": "/var/run/seccompaget.sock",
94
-"listenerMetadata": "opaque-metadata"
95
-}`)
96
-	rs := createSpec()
97
-	p, err := LoadProfile(string(profile), &rs)
98
-	if err != nil {
99
-		t.Fatal(err)
100
-	}
101
-
102
-	expected := specs.LinuxSeccomp{
103
-		DefaultAction:    specs.ActErrno,
104
-		ListenerPath:     "/var/run/seccompaget.sock",
105
-		ListenerMetadata: "opaque-metadata",
106
-	}
107
-
108
-	assertDeepEqual(t, expected, *p)
109
-}
110
-
111
-func TestLoadProfileWithFlag(t *testing.T) {
112
-	profile := `{"defaultAction": "SCMP_ACT_ERRNO", "flags": ["SECCOMP_FILTER_FLAG_SPEC_ALLOW", "SECCOMP_FILTER_FLAG_LOG"]}`
113
-	expected := specs.LinuxSeccomp{
114
-		DefaultAction: specs.ActErrno,
115
-		Flags:         []specs.LinuxSeccompFlag{"SECCOMP_FILTER_FLAG_SPEC_ALLOW", "SECCOMP_FILTER_FLAG_LOG"},
116
-	}
117
-	rs := createSpec()
118
-	p, err := LoadProfile(profile, &rs)
119
-	if err != nil {
120
-		t.Fatal(err)
121
-	}
122
-	assertDeepEqual(t, expected, *p)
123
-}
124
-
125
-// TestLoadProfileValidation tests that invalid profiles produce the correct error.
126
-func TestLoadProfileValidation(t *testing.T) {
127
-	tests := []struct {
128
-		doc      string
129
-		profile  string
130
-		expected string
131
-	}{
132
-		{
133
-			doc:      "conflicting architectures and archMap",
134
-			profile:  `{"defaultAction": "SCMP_ACT_ERRNO", "architectures": ["A", "B", "C"], "archMap": [{"architecture": "A", "subArchitectures": ["B", "C"]}]}`,
135
-			expected: `both 'architectures' and 'archMap' are specified in the seccomp profile, use either 'architectures' or 'archMap'`,
136
-		},
137
-		{
138
-			doc:      "conflicting syscall.name and syscall.names",
139
-			profile:  `{"defaultAction": "SCMP_ACT_ERRNO", "syscalls": [{"name": "accept", "names": ["accept"], "action": "SCMP_ACT_ALLOW"}]}`,
140
-			expected: `both 'name' and 'names' are specified in the seccomp profile, use either 'name' or 'names'`,
141
-		},
142
-	}
143
-	for _, tc := range tests {
144
-		rs := createSpec()
145
-		t.Run(tc.doc, func(t *testing.T) {
146
-			_, err := LoadProfile(tc.profile, &rs)
147
-			if err == nil {
148
-				t.Fatal("expected error")
149
-			}
150
-			if tc.expected != err.Error() {
151
-				t.Fatalf("expected: %q, got: %q", tc.expected, err)
152
-			}
153
-		})
154
-	}
155
-}
156
-
157
-// TestLoadLegacyProfile tests loading a seccomp profile in the old format
158
-// (before https://github.com/docker/docker/pull/24510)
159
-func TestLoadLegacyProfile(t *testing.T) {
160
-	f, err := os.ReadFile("fixtures/default-old-format.json")
161
-	if err != nil {
162
-		t.Fatal(err)
163
-	}
164
-	rs := createSpec()
165
-	p, err := LoadProfile(string(f), &rs)
166
-	if err != nil {
167
-		t.Fatal(err)
168
-	}
169
-	if p.DefaultAction != specs.ActErrno {
170
-		t.Fatalf("expected default action %s, got %s", specs.ActErrno, p.DefaultAction)
171
-	}
172
-	expectedArches := []specs.Arch{"SCMP_ARCH_X86_64", "SCMP_ARCH_X86", "SCMP_ARCH_X32"}
173
-	assertDeepEqual(t, expectedArches, p.Architectures)
174
-
175
-	if expected := 311; len(p.Syscalls) != expected {
176
-		t.Fatalf("expected %d syscalls, got %d", expected, len(p.Syscalls))
177
-	}
178
-	expected := specs.LinuxSyscall{
179
-		Names:  []string{"accept"},
180
-		Action: specs.ActAllow,
181
-		Args:   []specs.LinuxSeccompArg{},
182
-	}
183
-	assertDeepEqual(t, expected, p.Syscalls[0])
184
-}
185
-
186
-func TestLoadDefaultProfile(t *testing.T) {
187
-	f, err := os.ReadFile("default.json")
188
-	if err != nil {
189
-		t.Fatal(err)
190
-	}
191
-	rs := createSpec()
192
-	if _, err := LoadProfile(string(f), &rs); err != nil {
193
-		t.Fatal(err)
194
-	}
195
-}
196
-
197
-func TestUnmarshalDefaultProfile(t *testing.T) {
198
-	expected := DefaultProfile()
199
-	if expected == nil {
200
-		t.Skip("seccomp not supported")
201
-	}
202
-
203
-	f, err := os.ReadFile("default.json")
204
-	if err != nil {
205
-		t.Fatal(err)
206
-	}
207
-	var profile Seccomp
208
-	err = json.Unmarshal(f, &profile)
209
-	if err != nil {
210
-		t.Fatal(err)
211
-	}
212
-	assertDeepEqual(t, expected.Architectures, profile.Architectures)
213
-	assertDeepEqual(t, expected.ArchMap, profile.ArchMap)
214
-	assertDeepEqual(t, expected.DefaultAction, profile.DefaultAction)
215
-	assertDeepEqual(t, expected.Syscalls, profile.Syscalls)
216
-}
217
-
218
-func TestMarshalUnmarshalFilter(t *testing.T) {
219
-	t.Parallel()
220
-	tests := []struct {
221
-		in    string
222
-		out   string
223
-		error bool
224
-	}{
225
-		{in: `{"arches":["s390x"],"minKernel":3}`, error: true},
226
-		{in: `{"arches":["s390x"],"minKernel":3.12}`, error: true},
227
-		{in: `{"arches":["s390x"],"minKernel":true}`, error: true},
228
-		{in: `{"arches":["s390x"],"minKernel":"0.0"}`, error: true},
229
-		{in: `{"arches":["s390x"],"minKernel":"3"}`, error: true},
230
-		{in: `{"arches":["s390x"],"minKernel":".3"}`, error: true},
231
-		{in: `{"arches":["s390x"],"minKernel":"3."}`, error: true},
232
-		{in: `{"arches":["s390x"],"minKernel":"true"}`, error: true},
233
-		{in: `{"arches":["s390x"],"minKernel":"3.12.1\""}`, error: true},
234
-		{in: `{"arches":["s390x"],"minKernel":"4.15abc"}`, error: true},
235
-		{in: `{"arches":["s390x"],"minKernel":null}`, out: `{"arches":["s390x"]}`},
236
-		{in: `{"arches":["s390x"],"minKernel":""}`, out: `{"arches":["s390x"],"minKernel":""}`}, // FIXME: try to fix omitempty for this
237
-		{in: `{"arches":["s390x"],"minKernel":"0.5"}`, out: `{"arches":["s390x"],"minKernel":"0.5"}`},
238
-		{in: `{"arches":["s390x"],"minKernel":"0.50"}`, out: `{"arches":["s390x"],"minKernel":"0.50"}`},
239
-		{in: `{"arches":["s390x"],"minKernel":"5.0"}`, out: `{"arches":["s390x"],"minKernel":"5.0"}`},
240
-		{in: `{"arches":["s390x"],"minKernel":"50.0"}`, out: `{"arches":["s390x"],"minKernel":"50.0"}`},
241
-		{in: `{"arches":["s390x"],"minKernel":"4.15"}`, out: `{"arches":["s390x"],"minKernel":"4.15"}`},
242
-	}
243
-	for _, tc := range tests {
244
-		t.Run(tc.in, func(t *testing.T) {
245
-			var filter Filter
246
-			err := json.Unmarshal([]byte(tc.in), &filter)
247
-			if tc.error {
248
-				if err == nil {
249
-					t.Fatal("expected an error")
250
-				} else if !strings.Contains(err.Error(), "invalid kernel version") {
251
-					t.Fatal("unexpected error:", err)
252
-				}
253
-				return
254
-			}
255
-			if err != nil {
256
-				t.Fatal(err)
257
-			}
258
-			out, err := json.Marshal(filter)
259
-			if err != nil {
260
-				t.Fatal(err)
261
-			}
262
-			if string(out) != tc.out {
263
-				t.Fatalf("expected %s, got %s", tc.out, string(out))
264
-			}
265
-		})
266
-	}
267
-}
268
-
269
-func TestLoadConditional(t *testing.T) {
270
-	f, err := os.ReadFile("fixtures/conditional_include.json")
271
-	if err != nil {
272
-		t.Fatal(err)
273
-	}
274
-	tests := []struct {
275
-		doc      string
276
-		cap      string
277
-		expected []string
278
-	}{
279
-		{doc: "no caps", expected: []string{"chmod", "ptrace"}},
280
-		{doc: "with syslog", cap: "CAP_SYSLOG", expected: []string{"chmod", "syslog", "ptrace"}},
281
-		{doc: "no ptrace", cap: "CAP_SYS_ADMIN", expected: []string{"chmod"}},
282
-	}
283
-
284
-	for _, tc := range tests {
285
-		t.Run(tc.doc, func(t *testing.T) {
286
-			rs := createSpec(tc.cap)
287
-			p, err := LoadProfile(string(f), &rs)
288
-			if err != nil {
289
-				t.Fatal(err)
290
-			}
291
-			if len(p.Syscalls) != len(tc.expected) {
292
-				t.Fatalf("expected %d syscalls in profile, have %d", len(tc.expected), len(p.Syscalls))
293
-			}
294
-			for i, v := range p.Syscalls {
295
-				if v.Names[0] != tc.expected[i] {
296
-					t.Fatalf("expected %s syscall, have %s", tc.expected[i], v.Names[0])
297
-				}
298
-			}
299
-		})
300
-	}
301
-}
302
-
303
-// createSpec() creates a minimum spec for testing
304
-func createSpec(caps ...string) specs.Spec {
305
-	rs := specs.Spec{
306
-		Process: &specs.Process{
307
-			Capabilities: &specs.LinuxCapabilities{},
308
-		},
309
-	}
310
-	if caps != nil {
311
-		rs.Process.Capabilities.Bounding = append(rs.Process.Capabilities.Bounding, caps...)
312
-	}
313
-	return rs
314
-}
... ...
@@ -68,6 +68,8 @@ require (
68 68
 	github.com/moby/ipvs v1.1.0
69 69
 	github.com/moby/locker v1.0.1
70 70
 	github.com/moby/patternmatcher v0.6.0
71
+	github.com/moby/profiles/apparmor v0.1.0
72
+	github.com/moby/profiles/seccomp v0.1.0
71 73
 	github.com/moby/pubsub v1.0.0
72 74
 	github.com/moby/swarmkit/v2 v2.0.0
73 75
 	github.com/moby/sys/atomicwriter v0.1.0
... ...
@@ -395,6 +395,10 @@ github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
395 395
 github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
396 396
 github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
397 397
 github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
398
+github.com/moby/profiles/apparmor v0.1.0 h1:dMUt6fqdOeU9tfKjntPN9hBY1C5tJtsUWZNiIuHK8QM=
399
+github.com/moby/profiles/apparmor v0.1.0/go.mod h1:2iRxPw+MrPuDvmb5lAEAeLB1kcOt7AzZeW3paBs2TQY=
400
+github.com/moby/profiles/seccomp v0.1.0 h1:kVf1lc5ytNB1XPxEdZUVF+oPpbBYJHR50eEvPt/9k8A=
401
+github.com/moby/profiles/seccomp v0.1.0/go.mod h1:Kqk57vxH6/wuOc5bmqRiSXJ6iEz8Pvo3LQRkv0ytFWs=
398 402
 github.com/moby/pubsub v1.0.0 h1:jkp/imWsmJz2f6LyFsk7EkVeN2HxR/HTTOY8kHrsxfA=
399 403
 github.com/moby/pubsub v1.0.0/go.mod h1:bXSO+3h5MNXXCaEG+6/NlAIk7MMZbySZlnB+cUQhKKc=
400 404
 github.com/moby/swarmkit/v2 v2.0.0 h1:jkWQKQaJ4ltA61/mC9UdPe1McLma55RUcacTO+pPweY=
401 405
new file mode 100644
... ...
@@ -0,0 +1,202 @@
0
+
1
+                                 Apache License
2
+                           Version 2.0, January 2004
3
+                        http://www.apache.org/licenses/
4
+
5
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+   1. Definitions.
8
+
9
+      "License" shall mean the terms and conditions for use, reproduction,
10
+      and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+      "Licensor" shall mean the copyright owner or entity authorized by
13
+      the copyright owner that is granting the License.
14
+
15
+      "Legal Entity" shall mean the union of the acting entity and all
16
+      other entities that control, are controlled by, or are under common
17
+      control with that entity. For the purposes of this definition,
18
+      "control" means (i) the power, direct or indirect, to cause the
19
+      direction or management of such entity, whether by contract or
20
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+      outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+      "You" (or "Your") shall mean an individual or Legal Entity
24
+      exercising permissions granted by this License.
25
+
26
+      "Source" form shall mean the preferred form for making modifications,
27
+      including but not limited to software source code, documentation
28
+      source, and configuration files.
29
+
30
+      "Object" form shall mean any form resulting from mechanical
31
+      transformation or translation of a Source form, including but
32
+      not limited to compiled object code, generated documentation,
33
+      and conversions to other media types.
34
+
35
+      "Work" shall mean the work of authorship, whether in Source or
36
+      Object form, made available under the License, as indicated by a
37
+      copyright notice that is included in or attached to the work
38
+      (an example is provided in the Appendix below).
39
+
40
+      "Derivative Works" shall mean any work, whether in Source or Object
41
+      form, that is based on (or derived from) the Work and for which the
42
+      editorial revisions, annotations, elaborations, or other modifications
43
+      represent, as a whole, an original work of authorship. For the purposes
44
+      of this License, Derivative Works shall not include works that remain
45
+      separable from, or merely link (or bind by name) to the interfaces of,
46
+      the Work and Derivative Works thereof.
47
+
48
+      "Contribution" shall mean any work of authorship, including
49
+      the original version of the Work and any modifications or additions
50
+      to that Work or Derivative Works thereof, that is intentionally
51
+      submitted to Licensor for inclusion in the Work by the copyright owner
52
+      or by an individual or Legal Entity authorized to submit on behalf of
53
+      the copyright owner. For the purposes of this definition, "submitted"
54
+      means any form of electronic, verbal, or written communication sent
55
+      to the Licensor or its representatives, including but not limited to
56
+      communication on electronic mailing lists, source code control systems,
57
+      and issue tracking systems that are managed by, or on behalf of, the
58
+      Licensor for the purpose of discussing and improving the Work, but
59
+      excluding communication that is conspicuously marked or otherwise
60
+      designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+      "Contributor" shall mean Licensor and any individual or Legal Entity
63
+      on behalf of whom a Contribution has been received by Licensor and
64
+      subsequently incorporated within the Work.
65
+
66
+   2. Grant of Copyright License. Subject to the terms and conditions of
67
+      this License, each Contributor hereby grants to You a perpetual,
68
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+      copyright license to reproduce, prepare Derivative Works of,
70
+      publicly display, publicly perform, sublicense, and distribute the
71
+      Work and such Derivative Works in Source or Object form.
72
+
73
+   3. Grant of Patent License. Subject to the terms and conditions of
74
+      this License, each Contributor hereby grants to You a perpetual,
75
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+      (except as stated in this section) patent license to make, have made,
77
+      use, offer to sell, sell, import, and otherwise transfer the Work,
78
+      where such license applies only to those patent claims licensable
79
+      by such Contributor that are necessarily infringed by their
80
+      Contribution(s) alone or by combination of their Contribution(s)
81
+      with the Work to which such Contribution(s) was submitted. If You
82
+      institute patent litigation against any entity (including a
83
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+      or a Contribution incorporated within the Work constitutes direct
85
+      or contributory patent infringement, then any patent licenses
86
+      granted to You under this License for that Work shall terminate
87
+      as of the date such litigation is filed.
88
+
89
+   4. Redistribution. You may reproduce and distribute copies of the
90
+      Work or Derivative Works thereof in any medium, with or without
91
+      modifications, and in Source or Object form, provided that You
92
+      meet the following conditions:
93
+
94
+      (a) You must give any other recipients of the Work or
95
+          Derivative Works a copy of this License; and
96
+
97
+      (b) You must cause any modified files to carry prominent notices
98
+          stating that You changed the files; and
99
+
100
+      (c) You must retain, in the Source form of any Derivative Works
101
+          that You distribute, all copyright, patent, trademark, and
102
+          attribution notices from the Source form of the Work,
103
+          excluding those notices that do not pertain to any part of
104
+          the Derivative Works; and
105
+
106
+      (d) If the Work includes a "NOTICE" text file as part of its
107
+          distribution, then any Derivative Works that You distribute must
108
+          include a readable copy of the attribution notices contained
109
+          within such NOTICE file, excluding those notices that do not
110
+          pertain to any part of the Derivative Works, in at least one
111
+          of the following places: within a NOTICE text file distributed
112
+          as part of the Derivative Works; within the Source form or
113
+          documentation, if provided along with the Derivative Works; or,
114
+          within a display generated by the Derivative Works, if and
115
+          wherever such third-party notices normally appear. The contents
116
+          of the NOTICE file are for informational purposes only and
117
+          do not modify the License. You may add Your own attribution
118
+          notices within Derivative Works that You distribute, alongside
119
+          or as an addendum to the NOTICE text from the Work, provided
120
+          that such additional attribution notices cannot be construed
121
+          as modifying the License.
122
+
123
+      You may add Your own copyright statement to Your modifications and
124
+      may provide additional or different license terms and conditions
125
+      for use, reproduction, or distribution of Your modifications, or
126
+      for any such Derivative Works as a whole, provided Your use,
127
+      reproduction, and distribution of the Work otherwise complies with
128
+      the conditions stated in this License.
129
+
130
+   5. Submission of Contributions. Unless You explicitly state otherwise,
131
+      any Contribution intentionally submitted for inclusion in the Work
132
+      by You to the Licensor shall be under the terms and conditions of
133
+      this License, without any additional terms or conditions.
134
+      Notwithstanding the above, nothing herein shall supersede or modify
135
+      the terms of any separate license agreement you may have executed
136
+      with Licensor regarding such Contributions.
137
+
138
+   6. Trademarks. This License does not grant permission to use the trade
139
+      names, trademarks, service marks, or product names of the Licensor,
140
+      except as required for reasonable and customary use in describing the
141
+      origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+   7. Disclaimer of Warranty. Unless required by applicable law or
144
+      agreed to in writing, Licensor provides the Work (and each
145
+      Contributor provides its Contributions) on an "AS IS" BASIS,
146
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+      implied, including, without limitation, any warranties or conditions
148
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+      PARTICULAR PURPOSE. You are solely responsible for determining the
150
+      appropriateness of using or redistributing the Work and assume any
151
+      risks associated with Your exercise of permissions under this License.
152
+
153
+   8. Limitation of Liability. In no event and under no legal theory,
154
+      whether in tort (including negligence), contract, or otherwise,
155
+      unless required by applicable law (such as deliberate and grossly
156
+      negligent acts) or agreed to in writing, shall any Contributor be
157
+      liable to You for damages, including any direct, indirect, special,
158
+      incidental, or consequential damages of any character arising as a
159
+      result of this License or out of the use or inability to use the
160
+      Work (including but not limited to damages for loss of goodwill,
161
+      work stoppage, computer failure or malfunction, or any and all
162
+      other commercial damages or losses), even if such Contributor
163
+      has been advised of the possibility of such damages.
164
+
165
+   9. Accepting Warranty or Additional Liability. While redistributing
166
+      the Work or Derivative Works thereof, You may choose to offer,
167
+      and charge a fee for, acceptance of support, warranty, indemnity,
168
+      or other liability obligations and/or rights consistent with this
169
+      License. However, in accepting such obligations, You may act only
170
+      on Your own behalf and on Your sole responsibility, not on behalf
171
+      of any other Contributor, and only if You agree to indemnify,
172
+      defend, and hold each Contributor harmless for any liability
173
+      incurred by, or claims asserted against, such Contributor by reason
174
+      of your accepting any such warranty or additional liability.
175
+
176
+   END OF TERMS AND CONDITIONS
177
+
178
+   APPENDIX: How to apply the Apache License to your work.
179
+
180
+      To apply the Apache License to your work, attach the following
181
+      boilerplate notice, with the fields enclosed by brackets "[]"
182
+      replaced with your own identifying information. (Don't include
183
+      the brackets!)  The text should be enclosed in the appropriate
184
+      comment syntax for the file format. We also recommend that a
185
+      file or class name and description of purpose be included on the
186
+      same "printed page" as the copyright notice for easier
187
+      identification within third-party archives.
188
+
189
+   Copyright [yyyy] [name of copyright owner]
190
+
191
+   Licensed under the Apache License, Version 2.0 (the "License");
192
+   you may not use this file except in compliance with the License.
193
+   You may obtain a copy of the License at
194
+
195
+       http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+   Unless required by applicable law or agreed to in writing, software
198
+   distributed under the License is distributed on an "AS IS" BASIS,
199
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+   See the License for the specific language governing permissions and
201
+   limitations under the License.
0 202
new file mode 100644
... ...
@@ -0,0 +1,132 @@
0
+//go:build linux
1
+
2
+package apparmor
3
+
4
+import (
5
+	"bufio"
6
+	"fmt"
7
+	"io"
8
+	"os"
9
+	"os/exec"
10
+	"path"
11
+	"strings"
12
+	"text/template"
13
+)
14
+
15
+// profileDirectory is the file store for apparmor profiles and macros.
16
+const profileDirectory = "/etc/apparmor.d"
17
+
18
+// profileData holds information about the given profile for generation.
19
+type profileData struct {
20
+	// Name is profile name.
21
+	Name string
22
+	// DaemonProfile is the profile name of our daemon.
23
+	DaemonProfile string
24
+	// Imports defines the apparmor functions to import, before defining the profile.
25
+	Imports []string
26
+	// InnerImports defines the apparmor functions to import in the profile.
27
+	InnerImports []string
28
+}
29
+
30
+// generateDefault creates an apparmor profile from ProfileData.
31
+func (p *profileData) generateDefault(out io.Writer) error {
32
+	compiled, err := template.New("apparmor_profile").Parse(baseTemplate)
33
+	if err != nil {
34
+		return err
35
+	}
36
+
37
+	if macroExists("tunables/global") {
38
+		p.Imports = append(p.Imports, "#include <tunables/global>")
39
+	} else {
40
+		p.Imports = append(p.Imports, "@{PROC}=/proc/")
41
+	}
42
+
43
+	if macroExists("abstractions/base") {
44
+		p.InnerImports = append(p.InnerImports, "#include <abstractions/base>")
45
+	}
46
+
47
+	return compiled.Execute(out, p)
48
+}
49
+
50
+// macroExists checks if the passed macro exists.
51
+func macroExists(m string) bool {
52
+	_, err := os.Stat(path.Join(profileDirectory, m))
53
+	return err == nil
54
+}
55
+
56
+// InstallDefault generates a default profile in a temp directory determined by
57
+// os.TempDir(), then loads the profile into the kernel using 'apparmor_parser'.
58
+func InstallDefault(name string) error {
59
+	// Figure out the daemon profile.
60
+	daemonProfile := "unconfined"
61
+	if currentProfile, err := os.ReadFile("/proc/self/attr/current"); err == nil {
62
+		// Normally profiles are suffixed by " (enforcing)" or similar. AppArmor
63
+		// profiles cannot contain spaces so this doesn't restrict daemon profile
64
+		// names.
65
+		if profile, _, _ := strings.Cut(string(currentProfile), " "); profile != "" {
66
+			daemonProfile = profile
67
+		}
68
+	}
69
+
70
+	// Install to a temporary directory.
71
+	tmpFile, err := os.CreateTemp("", name)
72
+	if err != nil {
73
+		return err
74
+	}
75
+
76
+	defer func() {
77
+		_ = tmpFile.Close()
78
+		_ = os.Remove(tmpFile.Name())
79
+	}()
80
+
81
+	p := profileData{
82
+		Name:          name,
83
+		DaemonProfile: daemonProfile,
84
+	}
85
+	if err := p.generateDefault(tmpFile); err != nil {
86
+		return err
87
+	}
88
+
89
+	return loadProfile(tmpFile.Name())
90
+}
91
+
92
+// IsLoaded checks if a profile with the given name has been loaded into the
93
+// kernel.
94
+func IsLoaded(name string) (bool, error) {
95
+	return isLoaded(name, "/sys/kernel/security/apparmor/profiles")
96
+}
97
+
98
+func isLoaded(name string, fileName string) (bool, error) {
99
+	file, err := os.Open(fileName)
100
+	if err != nil {
101
+		return false, err
102
+	}
103
+	defer file.Close()
104
+
105
+	scanner := bufio.NewScanner(file)
106
+	for scanner.Scan() {
107
+		if prefix, _, ok := strings.Cut(scanner.Text(), " "); ok && prefix == name {
108
+			return true, nil
109
+		}
110
+	}
111
+
112
+	if err := scanner.Err(); err != nil {
113
+		return false, err
114
+	}
115
+
116
+	return false, nil
117
+}
118
+
119
+// loadProfile runs `apparmor_parser -Kr` on a specified apparmor profile to
120
+// replace the profile. The `-K` is necessary to make sure that apparmor_parser
121
+// doesn't try to write to a read-only filesystem.
122
+func loadProfile(profilePath string) error {
123
+	c := exec.Command("apparmor_parser", "-Kr", profilePath)
124
+	c.Dir = ""
125
+
126
+	if output, err := c.CombinedOutput(); err != nil {
127
+		return fmt.Errorf("running '%s' failed with output: %s\nerror: %v", c, output, err)
128
+	}
129
+
130
+	return nil
131
+}
0 132
new file mode 100644
... ...
@@ -0,0 +1,58 @@
0
+//go:build linux
1
+
2
+package apparmor
3
+
4
+// NOTE: This profile is replicated in containerd and libpod. If you make a
5
+//       change to this profile, please make follow-up PRs to those projects so
6
+//       that these rules can be synchronised (because any issue with this
7
+//       profile will likely affect libpod and containerd).
8
+
9
+// baseTemplate defines the default apparmor profile for containers.
10
+const baseTemplate = `
11
+{{range $value := .Imports}}
12
+{{$value}}
13
+{{end}}
14
+
15
+profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
16
+{{range $value := .InnerImports}}
17
+  {{$value}}
18
+{{end}}
19
+
20
+  network,
21
+  capability,
22
+  file,
23
+  umount,
24
+  # Host (privileged) processes may send signals to container processes.
25
+  signal (receive) peer=unconfined,
26
+  # runc may send signals to container processes (for "docker stop").
27
+  signal (receive) peer=runc,
28
+  # crun may send signals to container processes (for "docker stop" when used with crun OCI runtime).
29
+  signal (receive) peer=crun,
30
+  # dockerd may send signals to container processes (for "docker kill").
31
+  signal (receive) peer={{.DaemonProfile}},
32
+  # Container processes may send signals amongst themselves.
33
+  signal (send,receive) peer={{.Name}},
34
+
35
+  deny @{PROC}/* w,   # deny write for all files directly in /proc (not in a subdir)
36
+  # deny write to files not in /proc/<number>/** or /proc/sys/**
37
+  deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9/]*}/** w,
38
+  deny @{PROC}/sys/[^k]** w,  # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
39
+  deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w,  # deny everything except shm* in /proc/sys/kernel/
40
+  deny @{PROC}/sysrq-trigger rwklx,
41
+  deny @{PROC}/kcore rwklx,
42
+
43
+  deny mount,
44
+
45
+  deny /sys/[^f]*/** wklx,
46
+  deny /sys/f[^s]*/** wklx,
47
+  deny /sys/fs/[^c]*/** wklx,
48
+  deny /sys/fs/c[^g]*/** wklx,
49
+  deny /sys/fs/cg[^r]*/** wklx,
50
+  deny /sys/firmware/** rwklx,
51
+  deny /sys/devices/virtual/powercap/** rwklx,
52
+  deny /sys/kernel/security/** rwklx,
53
+
54
+  # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
55
+  ptrace (trace,read,tracedby,readby) peer={{.Name}},
56
+}
57
+`
0 58
new file mode 100644
... ...
@@ -0,0 +1,202 @@
0
+
1
+                                 Apache License
2
+                           Version 2.0, January 2004
3
+                        http://www.apache.org/licenses/
4
+
5
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+   1. Definitions.
8
+
9
+      "License" shall mean the terms and conditions for use, reproduction,
10
+      and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+      "Licensor" shall mean the copyright owner or entity authorized by
13
+      the copyright owner that is granting the License.
14
+
15
+      "Legal Entity" shall mean the union of the acting entity and all
16
+      other entities that control, are controlled by, or are under common
17
+      control with that entity. For the purposes of this definition,
18
+      "control" means (i) the power, direct or indirect, to cause the
19
+      direction or management of such entity, whether by contract or
20
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+      outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+      "You" (or "Your") shall mean an individual or Legal Entity
24
+      exercising permissions granted by this License.
25
+
26
+      "Source" form shall mean the preferred form for making modifications,
27
+      including but not limited to software source code, documentation
28
+      source, and configuration files.
29
+
30
+      "Object" form shall mean any form resulting from mechanical
31
+      transformation or translation of a Source form, including but
32
+      not limited to compiled object code, generated documentation,
33
+      and conversions to other media types.
34
+
35
+      "Work" shall mean the work of authorship, whether in Source or
36
+      Object form, made available under the License, as indicated by a
37
+      copyright notice that is included in or attached to the work
38
+      (an example is provided in the Appendix below).
39
+
40
+      "Derivative Works" shall mean any work, whether in Source or Object
41
+      form, that is based on (or derived from) the Work and for which the
42
+      editorial revisions, annotations, elaborations, or other modifications
43
+      represent, as a whole, an original work of authorship. For the purposes
44
+      of this License, Derivative Works shall not include works that remain
45
+      separable from, or merely link (or bind by name) to the interfaces of,
46
+      the Work and Derivative Works thereof.
47
+
48
+      "Contribution" shall mean any work of authorship, including
49
+      the original version of the Work and any modifications or additions
50
+      to that Work or Derivative Works thereof, that is intentionally
51
+      submitted to Licensor for inclusion in the Work by the copyright owner
52
+      or by an individual or Legal Entity authorized to submit on behalf of
53
+      the copyright owner. For the purposes of this definition, "submitted"
54
+      means any form of electronic, verbal, or written communication sent
55
+      to the Licensor or its representatives, including but not limited to
56
+      communication on electronic mailing lists, source code control systems,
57
+      and issue tracking systems that are managed by, or on behalf of, the
58
+      Licensor for the purpose of discussing and improving the Work, but
59
+      excluding communication that is conspicuously marked or otherwise
60
+      designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+      "Contributor" shall mean Licensor and any individual or Legal Entity
63
+      on behalf of whom a Contribution has been received by Licensor and
64
+      subsequently incorporated within the Work.
65
+
66
+   2. Grant of Copyright License. Subject to the terms and conditions of
67
+      this License, each Contributor hereby grants to You a perpetual,
68
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+      copyright license to reproduce, prepare Derivative Works of,
70
+      publicly display, publicly perform, sublicense, and distribute the
71
+      Work and such Derivative Works in Source or Object form.
72
+
73
+   3. Grant of Patent License. Subject to the terms and conditions of
74
+      this License, each Contributor hereby grants to You a perpetual,
75
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+      (except as stated in this section) patent license to make, have made,
77
+      use, offer to sell, sell, import, and otherwise transfer the Work,
78
+      where such license applies only to those patent claims licensable
79
+      by such Contributor that are necessarily infringed by their
80
+      Contribution(s) alone or by combination of their Contribution(s)
81
+      with the Work to which such Contribution(s) was submitted. If You
82
+      institute patent litigation against any entity (including a
83
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+      or a Contribution incorporated within the Work constitutes direct
85
+      or contributory patent infringement, then any patent licenses
86
+      granted to You under this License for that Work shall terminate
87
+      as of the date such litigation is filed.
88
+
89
+   4. Redistribution. You may reproduce and distribute copies of the
90
+      Work or Derivative Works thereof in any medium, with or without
91
+      modifications, and in Source or Object form, provided that You
92
+      meet the following conditions:
93
+
94
+      (a) You must give any other recipients of the Work or
95
+          Derivative Works a copy of this License; and
96
+
97
+      (b) You must cause any modified files to carry prominent notices
98
+          stating that You changed the files; and
99
+
100
+      (c) You must retain, in the Source form of any Derivative Works
101
+          that You distribute, all copyright, patent, trademark, and
102
+          attribution notices from the Source form of the Work,
103
+          excluding those notices that do not pertain to any part of
104
+          the Derivative Works; and
105
+
106
+      (d) If the Work includes a "NOTICE" text file as part of its
107
+          distribution, then any Derivative Works that You distribute must
108
+          include a readable copy of the attribution notices contained
109
+          within such NOTICE file, excluding those notices that do not
110
+          pertain to any part of the Derivative Works, in at least one
111
+          of the following places: within a NOTICE text file distributed
112
+          as part of the Derivative Works; within the Source form or
113
+          documentation, if provided along with the Derivative Works; or,
114
+          within a display generated by the Derivative Works, if and
115
+          wherever such third-party notices normally appear. The contents
116
+          of the NOTICE file are for informational purposes only and
117
+          do not modify the License. You may add Your own attribution
118
+          notices within Derivative Works that You distribute, alongside
119
+          or as an addendum to the NOTICE text from the Work, provided
120
+          that such additional attribution notices cannot be construed
121
+          as modifying the License.
122
+
123
+      You may add Your own copyright statement to Your modifications and
124
+      may provide additional or different license terms and conditions
125
+      for use, reproduction, or distribution of Your modifications, or
126
+      for any such Derivative Works as a whole, provided Your use,
127
+      reproduction, and distribution of the Work otherwise complies with
128
+      the conditions stated in this License.
129
+
130
+   5. Submission of Contributions. Unless You explicitly state otherwise,
131
+      any Contribution intentionally submitted for inclusion in the Work
132
+      by You to the Licensor shall be under the terms and conditions of
133
+      this License, without any additional terms or conditions.
134
+      Notwithstanding the above, nothing herein shall supersede or modify
135
+      the terms of any separate license agreement you may have executed
136
+      with Licensor regarding such Contributions.
137
+
138
+   6. Trademarks. This License does not grant permission to use the trade
139
+      names, trademarks, service marks, or product names of the Licensor,
140
+      except as required for reasonable and customary use in describing the
141
+      origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+   7. Disclaimer of Warranty. Unless required by applicable law or
144
+      agreed to in writing, Licensor provides the Work (and each
145
+      Contributor provides its Contributions) on an "AS IS" BASIS,
146
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+      implied, including, without limitation, any warranties or conditions
148
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+      PARTICULAR PURPOSE. You are solely responsible for determining the
150
+      appropriateness of using or redistributing the Work and assume any
151
+      risks associated with Your exercise of permissions under this License.
152
+
153
+   8. Limitation of Liability. In no event and under no legal theory,
154
+      whether in tort (including negligence), contract, or otherwise,
155
+      unless required by applicable law (such as deliberate and grossly
156
+      negligent acts) or agreed to in writing, shall any Contributor be
157
+      liable to You for damages, including any direct, indirect, special,
158
+      incidental, or consequential damages of any character arising as a
159
+      result of this License or out of the use or inability to use the
160
+      Work (including but not limited to damages for loss of goodwill,
161
+      work stoppage, computer failure or malfunction, or any and all
162
+      other commercial damages or losses), even if such Contributor
163
+      has been advised of the possibility of such damages.
164
+
165
+   9. Accepting Warranty or Additional Liability. While redistributing
166
+      the Work or Derivative Works thereof, You may choose to offer,
167
+      and charge a fee for, acceptance of support, warranty, indemnity,
168
+      or other liability obligations and/or rights consistent with this
169
+      License. However, in accepting such obligations, You may act only
170
+      on Your own behalf and on Your sole responsibility, not on behalf
171
+      of any other Contributor, and only if You agree to indemnify,
172
+      defend, and hold each Contributor harmless for any liability
173
+      incurred by, or claims asserted against, such Contributor by reason
174
+      of your accepting any such warranty or additional liability.
175
+
176
+   END OF TERMS AND CONDITIONS
177
+
178
+   APPENDIX: How to apply the Apache License to your work.
179
+
180
+      To apply the Apache License to your work, attach the following
181
+      boilerplate notice, with the fields enclosed by brackets "[]"
182
+      replaced with your own identifying information. (Don't include
183
+      the brackets!)  The text should be enclosed in the appropriate
184
+      comment syntax for the file format. We also recommend that a
185
+      file or class name and description of purpose be included on the
186
+      same "printed page" as the copyright notice for easier
187
+      identification within third-party archives.
188
+
189
+   Copyright [yyyy] [name of copyright owner]
190
+
191
+   Licensed under the Apache License, Version 2.0 (the "License");
192
+   you may not use this file except in compliance with the License.
193
+   You may obtain a copy of the License at
194
+
195
+       http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+   Unless required by applicable law or agreed to in writing, software
198
+   distributed under the License is distributed on an "AS IS" BASIS,
199
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+   See the License for the specific language governing permissions and
201
+   limitations under the License.
0 202
new file mode 100644
... ...
@@ -0,0 +1,845 @@
0
+{
1
+	"defaultAction": "SCMP_ACT_ERRNO",
2
+	"defaultErrnoRet": 1,
3
+	"archMap": [
4
+		{
5
+			"architecture": "SCMP_ARCH_X86_64",
6
+			"subArchitectures": [
7
+				"SCMP_ARCH_X86",
8
+				"SCMP_ARCH_X32"
9
+			]
10
+		},
11
+		{
12
+			"architecture": "SCMP_ARCH_AARCH64",
13
+			"subArchitectures": [
14
+				"SCMP_ARCH_ARM"
15
+			]
16
+		},
17
+		{
18
+			"architecture": "SCMP_ARCH_MIPS64",
19
+			"subArchitectures": [
20
+				"SCMP_ARCH_MIPS",
21
+				"SCMP_ARCH_MIPS64N32"
22
+			]
23
+		},
24
+		{
25
+			"architecture": "SCMP_ARCH_MIPS64N32",
26
+			"subArchitectures": [
27
+				"SCMP_ARCH_MIPS",
28
+				"SCMP_ARCH_MIPS64"
29
+			]
30
+		},
31
+		{
32
+			"architecture": "SCMP_ARCH_MIPSEL64",
33
+			"subArchitectures": [
34
+				"SCMP_ARCH_MIPSEL",
35
+				"SCMP_ARCH_MIPSEL64N32"
36
+			]
37
+		},
38
+		{
39
+			"architecture": "SCMP_ARCH_MIPSEL64N32",
40
+			"subArchitectures": [
41
+				"SCMP_ARCH_MIPSEL",
42
+				"SCMP_ARCH_MIPSEL64"
43
+			]
44
+		},
45
+		{
46
+			"architecture": "SCMP_ARCH_S390X",
47
+			"subArchitectures": [
48
+				"SCMP_ARCH_S390"
49
+			]
50
+		},
51
+		{
52
+			"architecture": "SCMP_ARCH_RISCV64",
53
+			"subArchitectures": null
54
+		}
55
+	],
56
+	"syscalls": [
57
+		{
58
+			"names": [
59
+				"accept",
60
+				"accept4",
61
+				"access",
62
+				"adjtimex",
63
+				"alarm",
64
+				"bind",
65
+				"brk",
66
+				"cachestat",
67
+				"capget",
68
+				"capset",
69
+				"chdir",
70
+				"chmod",
71
+				"chown",
72
+				"chown32",
73
+				"clock_adjtime",
74
+				"clock_adjtime64",
75
+				"clock_getres",
76
+				"clock_getres_time64",
77
+				"clock_gettime",
78
+				"clock_gettime64",
79
+				"clock_nanosleep",
80
+				"clock_nanosleep_time64",
81
+				"close",
82
+				"close_range",
83
+				"connect",
84
+				"copy_file_range",
85
+				"creat",
86
+				"dup",
87
+				"dup2",
88
+				"dup3",
89
+				"epoll_create",
90
+				"epoll_create1",
91
+				"epoll_ctl",
92
+				"epoll_ctl_old",
93
+				"epoll_pwait",
94
+				"epoll_pwait2",
95
+				"epoll_wait",
96
+				"epoll_wait_old",
97
+				"eventfd",
98
+				"eventfd2",
99
+				"execve",
100
+				"execveat",
101
+				"exit",
102
+				"exit_group",
103
+				"faccessat",
104
+				"faccessat2",
105
+				"fadvise64",
106
+				"fadvise64_64",
107
+				"fallocate",
108
+				"fanotify_mark",
109
+				"fchdir",
110
+				"fchmod",
111
+				"fchmodat",
112
+				"fchmodat2",
113
+				"fchown",
114
+				"fchown32",
115
+				"fchownat",
116
+				"fcntl",
117
+				"fcntl64",
118
+				"fdatasync",
119
+				"fgetxattr",
120
+				"flistxattr",
121
+				"flock",
122
+				"fork",
123
+				"fremovexattr",
124
+				"fsetxattr",
125
+				"fstat",
126
+				"fstat64",
127
+				"fstatat64",
128
+				"fstatfs",
129
+				"fstatfs64",
130
+				"fsync",
131
+				"ftruncate",
132
+				"ftruncate64",
133
+				"futex",
134
+				"futex_requeue",
135
+				"futex_time64",
136
+				"futex_wait",
137
+				"futex_waitv",
138
+				"futex_wake",
139
+				"futimesat",
140
+				"getcpu",
141
+				"getcwd",
142
+				"getdents",
143
+				"getdents64",
144
+				"getegid",
145
+				"getegid32",
146
+				"geteuid",
147
+				"geteuid32",
148
+				"getgid",
149
+				"getgid32",
150
+				"getgroups",
151
+				"getgroups32",
152
+				"getitimer",
153
+				"getpeername",
154
+				"getpgid",
155
+				"getpgrp",
156
+				"getpid",
157
+				"getppid",
158
+				"getpriority",
159
+				"getrandom",
160
+				"getresgid",
161
+				"getresgid32",
162
+				"getresuid",
163
+				"getresuid32",
164
+				"getrlimit",
165
+				"get_robust_list",
166
+				"getrusage",
167
+				"getsid",
168
+				"getsockname",
169
+				"getsockopt",
170
+				"get_thread_area",
171
+				"gettid",
172
+				"gettimeofday",
173
+				"getuid",
174
+				"getuid32",
175
+				"getxattr",
176
+				"getxattrat",
177
+				"inotify_add_watch",
178
+				"inotify_init",
179
+				"inotify_init1",
180
+				"inotify_rm_watch",
181
+				"io_cancel",
182
+				"ioctl",
183
+				"io_destroy",
184
+				"io_getevents",
185
+				"io_pgetevents",
186
+				"io_pgetevents_time64",
187
+				"ioprio_get",
188
+				"ioprio_set",
189
+				"io_setup",
190
+				"io_submit",
191
+				"ipc",
192
+				"kill",
193
+				"landlock_add_rule",
194
+				"landlock_create_ruleset",
195
+				"landlock_restrict_self",
196
+				"lchown",
197
+				"lchown32",
198
+				"lgetxattr",
199
+				"link",
200
+				"linkat",
201
+				"listen",
202
+				"listmount",
203
+				"listxattr",
204
+				"listxattrat",
205
+				"llistxattr",
206
+				"_llseek",
207
+				"lremovexattr",
208
+				"lseek",
209
+				"lsetxattr",
210
+				"lstat",
211
+				"lstat64",
212
+				"madvise",
213
+				"map_shadow_stack",
214
+				"membarrier",
215
+				"memfd_create",
216
+				"memfd_secret",
217
+				"mincore",
218
+				"mkdir",
219
+				"mkdirat",
220
+				"mknod",
221
+				"mknodat",
222
+				"mlock",
223
+				"mlock2",
224
+				"mlockall",
225
+				"mmap",
226
+				"mmap2",
227
+				"mprotect",
228
+				"mq_getsetattr",
229
+				"mq_notify",
230
+				"mq_open",
231
+				"mq_timedreceive",
232
+				"mq_timedreceive_time64",
233
+				"mq_timedsend",
234
+				"mq_timedsend_time64",
235
+				"mq_unlink",
236
+				"mremap",
237
+				"mseal",
238
+				"msgctl",
239
+				"msgget",
240
+				"msgrcv",
241
+				"msgsnd",
242
+				"msync",
243
+				"munlock",
244
+				"munlockall",
245
+				"munmap",
246
+				"name_to_handle_at",
247
+				"nanosleep",
248
+				"newfstatat",
249
+				"_newselect",
250
+				"open",
251
+				"openat",
252
+				"openat2",
253
+				"pause",
254
+				"pidfd_open",
255
+				"pidfd_send_signal",
256
+				"pipe",
257
+				"pipe2",
258
+				"pkey_alloc",
259
+				"pkey_free",
260
+				"pkey_mprotect",
261
+				"poll",
262
+				"ppoll",
263
+				"ppoll_time64",
264
+				"prctl",
265
+				"pread64",
266
+				"preadv",
267
+				"preadv2",
268
+				"prlimit64",
269
+				"process_mrelease",
270
+				"pselect6",
271
+				"pselect6_time64",
272
+				"pwrite64",
273
+				"pwritev",
274
+				"pwritev2",
275
+				"read",
276
+				"readahead",
277
+				"readlink",
278
+				"readlinkat",
279
+				"readv",
280
+				"recv",
281
+				"recvfrom",
282
+				"recvmmsg",
283
+				"recvmmsg_time64",
284
+				"recvmsg",
285
+				"remap_file_pages",
286
+				"removexattr",
287
+				"removexattrat",
288
+				"rename",
289
+				"renameat",
290
+				"renameat2",
291
+				"restart_syscall",
292
+				"riscv_hwprobe",
293
+				"rmdir",
294
+				"rseq",
295
+				"rt_sigaction",
296
+				"rt_sigpending",
297
+				"rt_sigprocmask",
298
+				"rt_sigqueueinfo",
299
+				"rt_sigreturn",
300
+				"rt_sigsuspend",
301
+				"rt_sigtimedwait",
302
+				"rt_sigtimedwait_time64",
303
+				"rt_tgsigqueueinfo",
304
+				"sched_getaffinity",
305
+				"sched_getattr",
306
+				"sched_getparam",
307
+				"sched_get_priority_max",
308
+				"sched_get_priority_min",
309
+				"sched_getscheduler",
310
+				"sched_rr_get_interval",
311
+				"sched_rr_get_interval_time64",
312
+				"sched_setaffinity",
313
+				"sched_setattr",
314
+				"sched_setparam",
315
+				"sched_setscheduler",
316
+				"sched_yield",
317
+				"seccomp",
318
+				"select",
319
+				"semctl",
320
+				"semget",
321
+				"semop",
322
+				"semtimedop",
323
+				"semtimedop_time64",
324
+				"send",
325
+				"sendfile",
326
+				"sendfile64",
327
+				"sendmmsg",
328
+				"sendmsg",
329
+				"sendto",
330
+				"setfsgid",
331
+				"setfsgid32",
332
+				"setfsuid",
333
+				"setfsuid32",
334
+				"setgid",
335
+				"setgid32",
336
+				"setgroups",
337
+				"setgroups32",
338
+				"setitimer",
339
+				"setpgid",
340
+				"setpriority",
341
+				"setregid",
342
+				"setregid32",
343
+				"setresgid",
344
+				"setresgid32",
345
+				"setresuid",
346
+				"setresuid32",
347
+				"setreuid",
348
+				"setreuid32",
349
+				"setrlimit",
350
+				"set_robust_list",
351
+				"setsid",
352
+				"setsockopt",
353
+				"set_thread_area",
354
+				"set_tid_address",
355
+				"setuid",
356
+				"setuid32",
357
+				"setxattr",
358
+				"setxattrat",
359
+				"shmat",
360
+				"shmctl",
361
+				"shmdt",
362
+				"shmget",
363
+				"shutdown",
364
+				"sigaltstack",
365
+				"signalfd",
366
+				"signalfd4",
367
+				"sigprocmask",
368
+				"sigreturn",
369
+				"socketcall",
370
+				"socketpair",
371
+				"splice",
372
+				"stat",
373
+				"stat64",
374
+				"statfs",
375
+				"statfs64",
376
+				"statmount",
377
+				"statx",
378
+				"symlink",
379
+				"symlinkat",
380
+				"sync",
381
+				"sync_file_range",
382
+				"syncfs",
383
+				"sysinfo",
384
+				"tee",
385
+				"tgkill",
386
+				"time",
387
+				"timer_create",
388
+				"timer_delete",
389
+				"timer_getoverrun",
390
+				"timer_gettime",
391
+				"timer_gettime64",
392
+				"timer_settime",
393
+				"timer_settime64",
394
+				"timerfd_create",
395
+				"timerfd_gettime",
396
+				"timerfd_gettime64",
397
+				"timerfd_settime",
398
+				"timerfd_settime64",
399
+				"times",
400
+				"tkill",
401
+				"truncate",
402
+				"truncate64",
403
+				"ugetrlimit",
404
+				"umask",
405
+				"uname",
406
+				"unlink",
407
+				"unlinkat",
408
+				"uretprobe",
409
+				"utime",
410
+				"utimensat",
411
+				"utimensat_time64",
412
+				"utimes",
413
+				"vfork",
414
+				"vmsplice",
415
+				"wait4",
416
+				"waitid",
417
+				"waitpid",
418
+				"write",
419
+				"writev"
420
+			],
421
+			"action": "SCMP_ACT_ALLOW"
422
+		},
423
+		{
424
+			"names": [
425
+				"process_vm_readv",
426
+				"process_vm_writev",
427
+				"ptrace"
428
+			],
429
+			"action": "SCMP_ACT_ALLOW",
430
+			"includes": {
431
+				"minKernel": "4.8"
432
+			}
433
+		},
434
+		{
435
+			"names": [
436
+				"socket"
437
+			],
438
+			"action": "SCMP_ACT_ALLOW",
439
+			"args": [
440
+				{
441
+					"index": 0,
442
+					"value": 40,
443
+					"op": "SCMP_CMP_NE"
444
+				}
445
+			]
446
+		},
447
+		{
448
+			"names": [
449
+				"personality"
450
+			],
451
+			"action": "SCMP_ACT_ALLOW",
452
+			"args": [
453
+				{
454
+					"index": 0,
455
+					"value": 0,
456
+					"op": "SCMP_CMP_EQ"
457
+				}
458
+			]
459
+		},
460
+		{
461
+			"names": [
462
+				"personality"
463
+			],
464
+			"action": "SCMP_ACT_ALLOW",
465
+			"args": [
466
+				{
467
+					"index": 0,
468
+					"value": 8,
469
+					"op": "SCMP_CMP_EQ"
470
+				}
471
+			]
472
+		},
473
+		{
474
+			"names": [
475
+				"personality"
476
+			],
477
+			"action": "SCMP_ACT_ALLOW",
478
+			"args": [
479
+				{
480
+					"index": 0,
481
+					"value": 131072,
482
+					"op": "SCMP_CMP_EQ"
483
+				}
484
+			]
485
+		},
486
+		{
487
+			"names": [
488
+				"personality"
489
+			],
490
+			"action": "SCMP_ACT_ALLOW",
491
+			"args": [
492
+				{
493
+					"index": 0,
494
+					"value": 131080,
495
+					"op": "SCMP_CMP_EQ"
496
+				}
497
+			]
498
+		},
499
+		{
500
+			"names": [
501
+				"personality"
502
+			],
503
+			"action": "SCMP_ACT_ALLOW",
504
+			"args": [
505
+				{
506
+					"index": 0,
507
+					"value": 4294967295,
508
+					"op": "SCMP_CMP_EQ"
509
+				}
510
+			]
511
+		},
512
+		{
513
+			"names": [
514
+				"sync_file_range2",
515
+				"swapcontext"
516
+			],
517
+			"action": "SCMP_ACT_ALLOW",
518
+			"includes": {
519
+				"arches": [
520
+					"ppc64le"
521
+				]
522
+			}
523
+		},
524
+		{
525
+			"names": [
526
+				"arm_fadvise64_64",
527
+				"arm_sync_file_range",
528
+				"sync_file_range2",
529
+				"breakpoint",
530
+				"cacheflush",
531
+				"set_tls"
532
+			],
533
+			"action": "SCMP_ACT_ALLOW",
534
+			"includes": {
535
+				"arches": [
536
+					"arm",
537
+					"arm64"
538
+				]
539
+			}
540
+		},
541
+		{
542
+			"names": [
543
+				"arch_prctl"
544
+			],
545
+			"action": "SCMP_ACT_ALLOW",
546
+			"includes": {
547
+				"arches": [
548
+					"amd64",
549
+					"x32"
550
+				]
551
+			}
552
+		},
553
+		{
554
+			"names": [
555
+				"modify_ldt"
556
+			],
557
+			"action": "SCMP_ACT_ALLOW",
558
+			"includes": {
559
+				"arches": [
560
+					"amd64",
561
+					"x32",
562
+					"x86"
563
+				]
564
+			}
565
+		},
566
+		{
567
+			"names": [
568
+				"s390_pci_mmio_read",
569
+				"s390_pci_mmio_write",
570
+				"s390_runtime_instr"
571
+			],
572
+			"action": "SCMP_ACT_ALLOW",
573
+			"includes": {
574
+				"arches": [
575
+					"s390",
576
+					"s390x"
577
+				]
578
+			}
579
+		},
580
+		{
581
+			"names": [
582
+				"riscv_flush_icache"
583
+			],
584
+			"action": "SCMP_ACT_ALLOW",
585
+			"includes": {
586
+				"arches": [
587
+					"riscv64"
588
+				]
589
+			}
590
+		},
591
+		{
592
+			"names": [
593
+				"open_by_handle_at"
594
+			],
595
+			"action": "SCMP_ACT_ALLOW",
596
+			"includes": {
597
+				"caps": [
598
+					"CAP_DAC_READ_SEARCH"
599
+				]
600
+			}
601
+		},
602
+		{
603
+			"names": [
604
+				"bpf",
605
+				"clone",
606
+				"clone3",
607
+				"fanotify_init",
608
+				"fsconfig",
609
+				"fsmount",
610
+				"fsopen",
611
+				"fspick",
612
+				"lookup_dcookie",
613
+				"lsm_get_self_attr",
614
+				"lsm_list_modules",
615
+				"lsm_set_self_attr",
616
+				"mount",
617
+				"mount_setattr",
618
+				"move_mount",
619
+				"open_tree",
620
+				"perf_event_open",
621
+				"quotactl",
622
+				"quotactl_fd",
623
+				"setdomainname",
624
+				"sethostname",
625
+				"setns",
626
+				"syslog",
627
+				"umount",
628
+				"umount2",
629
+				"unshare"
630
+			],
631
+			"action": "SCMP_ACT_ALLOW",
632
+			"includes": {
633
+				"caps": [
634
+					"CAP_SYS_ADMIN"
635
+				]
636
+			}
637
+		},
638
+		{
639
+			"names": [
640
+				"clone"
641
+			],
642
+			"action": "SCMP_ACT_ALLOW",
643
+			"args": [
644
+				{
645
+					"index": 0,
646
+					"value": 2114060288,
647
+					"op": "SCMP_CMP_MASKED_EQ"
648
+				}
649
+			],
650
+			"excludes": {
651
+				"caps": [
652
+					"CAP_SYS_ADMIN"
653
+				],
654
+				"arches": [
655
+					"s390",
656
+					"s390x"
657
+				]
658
+			}
659
+		},
660
+		{
661
+			"names": [
662
+				"clone"
663
+			],
664
+			"action": "SCMP_ACT_ALLOW",
665
+			"args": [
666
+				{
667
+					"index": 1,
668
+					"value": 2114060288,
669
+					"op": "SCMP_CMP_MASKED_EQ"
670
+				}
671
+			],
672
+			"comment": "s390 parameter ordering for clone is different",
673
+			"includes": {
674
+				"arches": [
675
+					"s390",
676
+					"s390x"
677
+				]
678
+			},
679
+			"excludes": {
680
+				"caps": [
681
+					"CAP_SYS_ADMIN"
682
+				]
683
+			}
684
+		},
685
+		{
686
+			"names": [
687
+				"clone3"
688
+			],
689
+			"action": "SCMP_ACT_ERRNO",
690
+			"errnoRet": 38,
691
+			"excludes": {
692
+				"caps": [
693
+					"CAP_SYS_ADMIN"
694
+				]
695
+			}
696
+		},
697
+		{
698
+			"names": [
699
+				"reboot"
700
+			],
701
+			"action": "SCMP_ACT_ALLOW",
702
+			"includes": {
703
+				"caps": [
704
+					"CAP_SYS_BOOT"
705
+				]
706
+			}
707
+		},
708
+		{
709
+			"names": [
710
+				"chroot"
711
+			],
712
+			"action": "SCMP_ACT_ALLOW",
713
+			"includes": {
714
+				"caps": [
715
+					"CAP_SYS_CHROOT"
716
+				]
717
+			}
718
+		},
719
+		{
720
+			"names": [
721
+				"delete_module",
722
+				"init_module",
723
+				"finit_module"
724
+			],
725
+			"action": "SCMP_ACT_ALLOW",
726
+			"includes": {
727
+				"caps": [
728
+					"CAP_SYS_MODULE"
729
+				]
730
+			}
731
+		},
732
+		{
733
+			"names": [
734
+				"acct"
735
+			],
736
+			"action": "SCMP_ACT_ALLOW",
737
+			"includes": {
738
+				"caps": [
739
+					"CAP_SYS_PACCT"
740
+				]
741
+			}
742
+		},
743
+		{
744
+			"names": [
745
+				"kcmp",
746
+				"pidfd_getfd",
747
+				"process_madvise",
748
+				"process_vm_readv",
749
+				"process_vm_writev",
750
+				"ptrace"
751
+			],
752
+			"action": "SCMP_ACT_ALLOW",
753
+			"includes": {
754
+				"caps": [
755
+					"CAP_SYS_PTRACE"
756
+				]
757
+			}
758
+		},
759
+		{
760
+			"names": [
761
+				"iopl",
762
+				"ioperm"
763
+			],
764
+			"action": "SCMP_ACT_ALLOW",
765
+			"includes": {
766
+				"caps": [
767
+					"CAP_SYS_RAWIO"
768
+				]
769
+			}
770
+		},
771
+		{
772
+			"names": [
773
+				"settimeofday",
774
+				"stime",
775
+				"clock_settime",
776
+				"clock_settime64"
777
+			],
778
+			"action": "SCMP_ACT_ALLOW",
779
+			"includes": {
780
+				"caps": [
781
+					"CAP_SYS_TIME"
782
+				]
783
+			}
784
+		},
785
+		{
786
+			"names": [
787
+				"vhangup"
788
+			],
789
+			"action": "SCMP_ACT_ALLOW",
790
+			"includes": {
791
+				"caps": [
792
+					"CAP_SYS_TTY_CONFIG"
793
+				]
794
+			}
795
+		},
796
+		{
797
+			"names": [
798
+				"get_mempolicy",
799
+				"mbind",
800
+				"set_mempolicy",
801
+				"set_mempolicy_home_node"
802
+			],
803
+			"action": "SCMP_ACT_ALLOW",
804
+			"includes": {
805
+				"caps": [
806
+					"CAP_SYS_NICE"
807
+				]
808
+			}
809
+		},
810
+		{
811
+			"names": [
812
+				"syslog"
813
+			],
814
+			"action": "SCMP_ACT_ALLOW",
815
+			"includes": {
816
+				"caps": [
817
+					"CAP_SYSLOG"
818
+				]
819
+			}
820
+		},
821
+		{
822
+			"names": [
823
+				"bpf"
824
+			],
825
+			"action": "SCMP_ACT_ALLOW",
826
+			"includes": {
827
+				"caps": [
828
+					"CAP_BPF"
829
+				]
830
+			}
831
+		},
832
+		{
833
+			"names": [
834
+				"perf_event_open"
835
+			],
836
+			"action": "SCMP_ACT_ALLOW",
837
+			"includes": {
838
+				"caps": [
839
+					"CAP_PERFMON"
840
+				]
841
+			}
842
+		}
843
+	]
844
+}
0 845
\ No newline at end of file
1 846
new file mode 100644
... ...
@@ -0,0 +1,841 @@
0
+package seccomp
1
+
2
+import (
3
+	"github.com/opencontainers/runtime-spec/specs-go"
4
+	"golang.org/x/sys/unix"
5
+)
6
+
7
+func arches() []Architecture {
8
+	return []Architecture{
9
+		{
10
+			Arch:      specs.ArchX86_64,
11
+			SubArches: []specs.Arch{specs.ArchX86, specs.ArchX32},
12
+		},
13
+		{
14
+			Arch:      specs.ArchAARCH64,
15
+			SubArches: []specs.Arch{specs.ArchARM},
16
+		},
17
+		{
18
+			Arch:      specs.ArchMIPS64,
19
+			SubArches: []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64N32},
20
+		},
21
+		{
22
+			Arch:      specs.ArchMIPS64N32,
23
+			SubArches: []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64},
24
+		},
25
+		{
26
+			Arch:      specs.ArchMIPSEL64,
27
+			SubArches: []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64N32},
28
+		},
29
+		{
30
+			Arch:      specs.ArchMIPSEL64N32,
31
+			SubArches: []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64},
32
+		},
33
+		{
34
+			Arch:      specs.ArchS390X,
35
+			SubArches: []specs.Arch{specs.ArchS390},
36
+		},
37
+		{
38
+			Arch:      specs.ArchRISCV64,
39
+			SubArches: nil,
40
+		},
41
+	}
42
+}
43
+
44
+// DefaultProfile defines the allowed syscalls for the default seccomp profile.
45
+func DefaultProfile() *Seccomp {
46
+	nosys := uint(unix.ENOSYS)
47
+	syscalls := []*Syscall{
48
+		{
49
+			LinuxSyscall: specs.LinuxSyscall{
50
+				Names: []string{
51
+					"accept",
52
+					"accept4",
53
+					"access",
54
+					"adjtimex",
55
+					"alarm",
56
+					"bind",
57
+					"brk",
58
+					"cachestat", // kernel v6.5, libseccomp v2.5.5
59
+					"capget",
60
+					"capset",
61
+					"chdir",
62
+					"chmod",
63
+					"chown",
64
+					"chown32",
65
+					"clock_adjtime",
66
+					"clock_adjtime64",
67
+					"clock_getres",
68
+					"clock_getres_time64",
69
+					"clock_gettime",
70
+					"clock_gettime64",
71
+					"clock_nanosleep",
72
+					"clock_nanosleep_time64",
73
+					"close",
74
+					"close_range",
75
+					"connect",
76
+					"copy_file_range",
77
+					"creat",
78
+					"dup",
79
+					"dup2",
80
+					"dup3",
81
+					"epoll_create",
82
+					"epoll_create1",
83
+					"epoll_ctl",
84
+					"epoll_ctl_old",
85
+					"epoll_pwait",
86
+					"epoll_pwait2",
87
+					"epoll_wait",
88
+					"epoll_wait_old",
89
+					"eventfd",
90
+					"eventfd2",
91
+					"execve",
92
+					"execveat",
93
+					"exit",
94
+					"exit_group",
95
+					"faccessat",
96
+					"faccessat2",
97
+					"fadvise64",
98
+					"fadvise64_64",
99
+					"fallocate",
100
+					"fanotify_mark",
101
+					"fchdir",
102
+					"fchmod",
103
+					"fchmodat",
104
+					"fchmodat2", // kernel v6.6, libseccomp v2.5.5
105
+					"fchown",
106
+					"fchown32",
107
+					"fchownat",
108
+					"fcntl",
109
+					"fcntl64",
110
+					"fdatasync",
111
+					"fgetxattr",
112
+					"flistxattr",
113
+					"flock",
114
+					"fork",
115
+					"fremovexattr",
116
+					"fsetxattr",
117
+					"fstat",
118
+					"fstat64",
119
+					"fstatat64",
120
+					"fstatfs",
121
+					"fstatfs64",
122
+					"fsync",
123
+					"ftruncate",
124
+					"ftruncate64",
125
+					"futex",
126
+					"futex_requeue", // kernel v6.7, libseccomp v2.5.5
127
+					"futex_time64",
128
+					"futex_wait", // kernel v6.7, libseccomp v2.5.5
129
+					"futex_waitv",
130
+					"futex_wake", // kernel v6.7, libseccomp v2.5.5
131
+					"futimesat",
132
+					"getcpu",
133
+					"getcwd",
134
+					"getdents",
135
+					"getdents64",
136
+					"getegid",
137
+					"getegid32",
138
+					"geteuid",
139
+					"geteuid32",
140
+					"getgid",
141
+					"getgid32",
142
+					"getgroups",
143
+					"getgroups32",
144
+					"getitimer",
145
+					"getpeername",
146
+					"getpgid",
147
+					"getpgrp",
148
+					"getpid",
149
+					"getppid",
150
+					"getpriority",
151
+					"getrandom",
152
+					"getresgid",
153
+					"getresgid32",
154
+					"getresuid",
155
+					"getresuid32",
156
+					"getrlimit",
157
+					"get_robust_list",
158
+					"getrusage",
159
+					"getsid",
160
+					"getsockname",
161
+					"getsockopt",
162
+					"get_thread_area",
163
+					"gettid",
164
+					"gettimeofday",
165
+					"getuid",
166
+					"getuid32",
167
+					"getxattr",
168
+					"getxattrat", // kernel v6.13, libseccomp v2.6.0
169
+					"inotify_add_watch",
170
+					"inotify_init",
171
+					"inotify_init1",
172
+					"inotify_rm_watch",
173
+					"io_cancel",
174
+					"ioctl",
175
+					"io_destroy",
176
+					"io_getevents",
177
+					"io_pgetevents",
178
+					"io_pgetevents_time64",
179
+					"ioprio_get",
180
+					"ioprio_set",
181
+					"io_setup",
182
+					"io_submit",
183
+					"ipc",
184
+					"kill",
185
+					"landlock_add_rule",
186
+					"landlock_create_ruleset",
187
+					"landlock_restrict_self",
188
+					"lchown",
189
+					"lchown32",
190
+					"lgetxattr",
191
+					"link",
192
+					"linkat",
193
+					"listen",
194
+					"listmount", // kernel v6.8, libseccomp v2.6.0
195
+					"listxattr",
196
+					"listxattrat", // kernel v6.13, libseccomp v2.6.0
197
+					"llistxattr",
198
+					"_llseek",
199
+					"lremovexattr",
200
+					"lseek",
201
+					"lsetxattr",
202
+					"lstat",
203
+					"lstat64",
204
+					"madvise",
205
+					"map_shadow_stack", // kernel v6.6, libseccomp v2.5.5
206
+					"membarrier",
207
+					"memfd_create",
208
+					"memfd_secret",
209
+					"mincore",
210
+					"mkdir",
211
+					"mkdirat",
212
+					"mknod",
213
+					"mknodat",
214
+					"mlock",
215
+					"mlock2",
216
+					"mlockall",
217
+					"mmap",
218
+					"mmap2",
219
+					"mprotect",
220
+					"mq_getsetattr",
221
+					"mq_notify",
222
+					"mq_open",
223
+					"mq_timedreceive",
224
+					"mq_timedreceive_time64",
225
+					"mq_timedsend",
226
+					"mq_timedsend_time64",
227
+					"mq_unlink",
228
+					"mremap",
229
+					"mseal", // kernel v6.9, libseccomp v2.6.0
230
+					"msgctl",
231
+					"msgget",
232
+					"msgrcv",
233
+					"msgsnd",
234
+					"msync",
235
+					"munlock",
236
+					"munlockall",
237
+					"munmap",
238
+					"name_to_handle_at",
239
+					"nanosleep",
240
+					"newfstatat",
241
+					"_newselect",
242
+					"open",
243
+					"openat",
244
+					"openat2",
245
+					"pause",
246
+					"pidfd_open",
247
+					"pidfd_send_signal",
248
+					"pipe",
249
+					"pipe2",
250
+					"pkey_alloc",
251
+					"pkey_free",
252
+					"pkey_mprotect",
253
+					"poll",
254
+					"ppoll",
255
+					"ppoll_time64",
256
+					"prctl",
257
+					"pread64",
258
+					"preadv",
259
+					"preadv2",
260
+					"prlimit64",
261
+					"process_mrelease",
262
+					"pselect6",
263
+					"pselect6_time64",
264
+					"pwrite64",
265
+					"pwritev",
266
+					"pwritev2",
267
+					"read",
268
+					"readahead",
269
+					"readlink",
270
+					"readlinkat",
271
+					"readv",
272
+					"recv",
273
+					"recvfrom",
274
+					"recvmmsg",
275
+					"recvmmsg_time64",
276
+					"recvmsg",
277
+					"remap_file_pages",
278
+					"removexattr",
279
+					"removexattrat", // kernel v6.13, libseccomp v2.6.0
280
+					"rename",
281
+					"renameat",
282
+					"renameat2",
283
+					"restart_syscall",
284
+					"riscv_hwprobe", // kernel v6.12, libseccomp v2.6.0
285
+					"rmdir",
286
+					"rseq",
287
+					"rt_sigaction",
288
+					"rt_sigpending",
289
+					"rt_sigprocmask",
290
+					"rt_sigqueueinfo",
291
+					"rt_sigreturn",
292
+					"rt_sigsuspend",
293
+					"rt_sigtimedwait",
294
+					"rt_sigtimedwait_time64",
295
+					"rt_tgsigqueueinfo",
296
+					"sched_getaffinity",
297
+					"sched_getattr",
298
+					"sched_getparam",
299
+					"sched_get_priority_max",
300
+					"sched_get_priority_min",
301
+					"sched_getscheduler",
302
+					"sched_rr_get_interval",
303
+					"sched_rr_get_interval_time64",
304
+					"sched_setaffinity",
305
+					"sched_setattr",
306
+					"sched_setparam",
307
+					"sched_setscheduler",
308
+					"sched_yield",
309
+					"seccomp",
310
+					"select",
311
+					"semctl",
312
+					"semget",
313
+					"semop",
314
+					"semtimedop",
315
+					"semtimedop_time64",
316
+					"send",
317
+					"sendfile",
318
+					"sendfile64",
319
+					"sendmmsg",
320
+					"sendmsg",
321
+					"sendto",
322
+					"setfsgid",
323
+					"setfsgid32",
324
+					"setfsuid",
325
+					"setfsuid32",
326
+					"setgid",
327
+					"setgid32",
328
+					"setgroups",
329
+					"setgroups32",
330
+					"setitimer",
331
+					"setpgid",
332
+					"setpriority",
333
+					"setregid",
334
+					"setregid32",
335
+					"setresgid",
336
+					"setresgid32",
337
+					"setresuid",
338
+					"setresuid32",
339
+					"setreuid",
340
+					"setreuid32",
341
+					"setrlimit",
342
+					"set_robust_list",
343
+					"setsid",
344
+					"setsockopt",
345
+					"set_thread_area",
346
+					"set_tid_address",
347
+					"setuid",
348
+					"setuid32",
349
+					"setxattr",
350
+					"setxattrat", // kernel v6.13, libseccomp v2.6.0
351
+					"shmat",
352
+					"shmctl",
353
+					"shmdt",
354
+					"shmget",
355
+					"shutdown",
356
+					"sigaltstack",
357
+					"signalfd",
358
+					"signalfd4",
359
+					"sigprocmask",
360
+					"sigreturn",
361
+					"socketcall",
362
+					"socketpair",
363
+					"splice",
364
+					"stat",
365
+					"stat64",
366
+					"statfs",
367
+					"statfs64",
368
+					"statmount", // kernel v6.8, libseccomp v2.6.0
369
+					"statx",
370
+					"symlink",
371
+					"symlinkat",
372
+					"sync",
373
+					"sync_file_range",
374
+					"syncfs",
375
+					"sysinfo",
376
+					"tee",
377
+					"tgkill",
378
+					"time",
379
+					"timer_create",
380
+					"timer_delete",
381
+					"timer_getoverrun",
382
+					"timer_gettime",
383
+					"timer_gettime64",
384
+					"timer_settime",
385
+					"timer_settime64",
386
+					"timerfd_create",
387
+					"timerfd_gettime",
388
+					"timerfd_gettime64",
389
+					"timerfd_settime",
390
+					"timerfd_settime64",
391
+					"times",
392
+					"tkill",
393
+					"truncate",
394
+					"truncate64",
395
+					"ugetrlimit",
396
+					"umask",
397
+					"uname",
398
+					"unlink",
399
+					"unlinkat",
400
+					"uretprobe", // kernel v6.11, libseccomp v2.6.0
401
+					"utime",
402
+					"utimensat",
403
+					"utimensat_time64",
404
+					"utimes",
405
+					"vfork",
406
+					"vmsplice",
407
+					"wait4",
408
+					"waitid",
409
+					"waitpid",
410
+					"write",
411
+					"writev",
412
+				},
413
+				Action: specs.ActAllow,
414
+			},
415
+		},
416
+		{
417
+			LinuxSyscall: specs.LinuxSyscall{
418
+				Names: []string{
419
+					"process_vm_readv",
420
+					"process_vm_writev",
421
+					"ptrace",
422
+				},
423
+				Action: specs.ActAllow,
424
+			},
425
+			Includes: &Filter{
426
+				MinKernel: &KernelVersion{4, 8},
427
+			},
428
+		},
429
+		{
430
+			LinuxSyscall: specs.LinuxSyscall{
431
+				Names:  []string{"socket"},
432
+				Action: specs.ActAllow,
433
+				Args: []specs.LinuxSeccompArg{
434
+					{
435
+						Index: 0,
436
+						Value: unix.AF_VSOCK,
437
+						Op:    specs.OpNotEqual,
438
+					},
439
+				},
440
+			},
441
+		},
442
+		{
443
+			LinuxSyscall: specs.LinuxSyscall{
444
+				Names:  []string{"personality"},
445
+				Action: specs.ActAllow,
446
+				Args: []specs.LinuxSeccompArg{
447
+					{
448
+						Index: 0,
449
+						Value: 0x0,
450
+						Op:    specs.OpEqualTo,
451
+					},
452
+				},
453
+			},
454
+		},
455
+		{
456
+			LinuxSyscall: specs.LinuxSyscall{
457
+				Names:  []string{"personality"},
458
+				Action: specs.ActAllow,
459
+				Args: []specs.LinuxSeccompArg{
460
+					{
461
+						Index: 0,
462
+						Value: 0x0008,
463
+						Op:    specs.OpEqualTo,
464
+					},
465
+				},
466
+			},
467
+		},
468
+		{
469
+			LinuxSyscall: specs.LinuxSyscall{
470
+				Names:  []string{"personality"},
471
+				Action: specs.ActAllow,
472
+				Args: []specs.LinuxSeccompArg{
473
+					{
474
+						Index: 0,
475
+						Value: 0x20000,
476
+						Op:    specs.OpEqualTo,
477
+					},
478
+				},
479
+			},
480
+		},
481
+		{
482
+			LinuxSyscall: specs.LinuxSyscall{
483
+				Names:  []string{"personality"},
484
+				Action: specs.ActAllow,
485
+				Args: []specs.LinuxSeccompArg{
486
+					{
487
+						Index: 0,
488
+						Value: 0x20008,
489
+						Op:    specs.OpEqualTo,
490
+					},
491
+				},
492
+			},
493
+		},
494
+		{
495
+			LinuxSyscall: specs.LinuxSyscall{
496
+				Names:  []string{"personality"},
497
+				Action: specs.ActAllow,
498
+				Args: []specs.LinuxSeccompArg{
499
+					{
500
+						Index: 0,
501
+						Value: 0xffffffff,
502
+						Op:    specs.OpEqualTo,
503
+					},
504
+				},
505
+			},
506
+		},
507
+		{
508
+			LinuxSyscall: specs.LinuxSyscall{
509
+				Names: []string{
510
+					"sync_file_range2",
511
+					"swapcontext",
512
+				},
513
+				Action: specs.ActAllow,
514
+			},
515
+			Includes: &Filter{
516
+				Arches: []string{"ppc64le"},
517
+			},
518
+		},
519
+		{
520
+			LinuxSyscall: specs.LinuxSyscall{
521
+				Names: []string{
522
+					"arm_fadvise64_64",
523
+					"arm_sync_file_range",
524
+					"sync_file_range2",
525
+					"breakpoint",
526
+					"cacheflush",
527
+					"set_tls",
528
+				},
529
+				Action: specs.ActAllow,
530
+			},
531
+			Includes: &Filter{
532
+				Arches: []string{"arm", "arm64"},
533
+			},
534
+		},
535
+		{
536
+			LinuxSyscall: specs.LinuxSyscall{
537
+				Names: []string{
538
+					"arch_prctl",
539
+				},
540
+				Action: specs.ActAllow,
541
+			},
542
+			Includes: &Filter{
543
+				Arches: []string{"amd64", "x32"},
544
+			},
545
+		},
546
+		{
547
+			LinuxSyscall: specs.LinuxSyscall{
548
+				Names: []string{
549
+					"modify_ldt",
550
+				},
551
+				Action: specs.ActAllow,
552
+			},
553
+			Includes: &Filter{
554
+				Arches: []string{"amd64", "x32", "x86"},
555
+			},
556
+		},
557
+		{
558
+			LinuxSyscall: specs.LinuxSyscall{
559
+				Names: []string{
560
+					"s390_pci_mmio_read",
561
+					"s390_pci_mmio_write",
562
+					"s390_runtime_instr",
563
+				},
564
+				Action: specs.ActAllow,
565
+			},
566
+			Includes: &Filter{
567
+				Arches: []string{"s390", "s390x"},
568
+			},
569
+		},
570
+		{
571
+			LinuxSyscall: specs.LinuxSyscall{
572
+				Names: []string{
573
+					"riscv_flush_icache",
574
+				},
575
+				Action: specs.ActAllow,
576
+			},
577
+			Includes: &Filter{
578
+				Arches: []string{"riscv64"},
579
+			},
580
+		},
581
+		{
582
+			LinuxSyscall: specs.LinuxSyscall{
583
+				Names: []string{
584
+					"open_by_handle_at",
585
+				},
586
+				Action: specs.ActAllow,
587
+			},
588
+			Includes: &Filter{
589
+				Caps: []string{"CAP_DAC_READ_SEARCH"},
590
+			},
591
+		},
592
+		{
593
+			LinuxSyscall: specs.LinuxSyscall{
594
+				Names: []string{
595
+					"bpf",
596
+					"clone",
597
+					"clone3",
598
+					"fanotify_init",
599
+					"fsconfig",
600
+					"fsmount",
601
+					"fsopen",
602
+					"fspick",
603
+					"lookup_dcookie",
604
+					"lsm_get_self_attr", // kernel v6.8, libseccomp v2.6.0
605
+					"lsm_list_modules",  // kernel v6.8, libseccomp v2.6.0
606
+					"lsm_set_self_attr", // kernel v6.8, libseccomp v2.6.0
607
+					"mount",
608
+					"mount_setattr",
609
+					"move_mount",
610
+					"open_tree",
611
+					"perf_event_open",
612
+					"quotactl",
613
+					"quotactl_fd",
614
+					"setdomainname",
615
+					"sethostname",
616
+					"setns",
617
+					"syslog",
618
+					"umount",
619
+					"umount2",
620
+					"unshare",
621
+				},
622
+				Action: specs.ActAllow,
623
+			},
624
+			Includes: &Filter{
625
+				Caps: []string{"CAP_SYS_ADMIN"},
626
+			},
627
+		},
628
+		{
629
+			LinuxSyscall: specs.LinuxSyscall{
630
+				Names: []string{
631
+					"clone",
632
+				},
633
+				Action: specs.ActAllow,
634
+				Args: []specs.LinuxSeccompArg{
635
+					{
636
+						Index:    0,
637
+						Value:    unix.CLONE_NEWNS | unix.CLONE_NEWUTS | unix.CLONE_NEWIPC | unix.CLONE_NEWUSER | unix.CLONE_NEWPID | unix.CLONE_NEWNET | unix.CLONE_NEWCGROUP,
638
+						ValueTwo: 0,
639
+						Op:       specs.OpMaskedEqual,
640
+					},
641
+				},
642
+			},
643
+			Excludes: &Filter{
644
+				Caps:   []string{"CAP_SYS_ADMIN"},
645
+				Arches: []string{"s390", "s390x"},
646
+			},
647
+		},
648
+		{
649
+			LinuxSyscall: specs.LinuxSyscall{
650
+				Names: []string{
651
+					"clone",
652
+				},
653
+				Action: specs.ActAllow,
654
+				Args: []specs.LinuxSeccompArg{
655
+					{
656
+						Index:    1,
657
+						Value:    unix.CLONE_NEWNS | unix.CLONE_NEWUTS | unix.CLONE_NEWIPC | unix.CLONE_NEWUSER | unix.CLONE_NEWPID | unix.CLONE_NEWNET | unix.CLONE_NEWCGROUP,
658
+						ValueTwo: 0,
659
+						Op:       specs.OpMaskedEqual,
660
+					},
661
+				},
662
+			},
663
+			Comment: "s390 parameter ordering for clone is different",
664
+			Includes: &Filter{
665
+				Arches: []string{"s390", "s390x"},
666
+			},
667
+			Excludes: &Filter{
668
+				Caps: []string{"CAP_SYS_ADMIN"},
669
+			},
670
+		},
671
+		{
672
+			LinuxSyscall: specs.LinuxSyscall{
673
+				Names: []string{
674
+					"clone3",
675
+				},
676
+				Action:   specs.ActErrno,
677
+				ErrnoRet: &nosys,
678
+			},
679
+			Excludes: &Filter{
680
+				Caps: []string{"CAP_SYS_ADMIN"},
681
+			},
682
+		},
683
+		{
684
+			LinuxSyscall: specs.LinuxSyscall{
685
+				Names: []string{
686
+					"reboot",
687
+				},
688
+				Action: specs.ActAllow,
689
+			},
690
+			Includes: &Filter{
691
+				Caps: []string{"CAP_SYS_BOOT"},
692
+			},
693
+		},
694
+		{
695
+			LinuxSyscall: specs.LinuxSyscall{
696
+				Names: []string{
697
+					"chroot",
698
+				},
699
+				Action: specs.ActAllow,
700
+			},
701
+			Includes: &Filter{
702
+				Caps: []string{"CAP_SYS_CHROOT"},
703
+			},
704
+		},
705
+		{
706
+			LinuxSyscall: specs.LinuxSyscall{
707
+				Names: []string{
708
+					"delete_module",
709
+					"init_module",
710
+					"finit_module",
711
+				},
712
+				Action: specs.ActAllow,
713
+			},
714
+			Includes: &Filter{
715
+				Caps: []string{"CAP_SYS_MODULE"},
716
+			},
717
+		},
718
+		{
719
+			LinuxSyscall: specs.LinuxSyscall{
720
+				Names: []string{
721
+					"acct",
722
+				},
723
+				Action: specs.ActAllow,
724
+			},
725
+			Includes: &Filter{
726
+				Caps: []string{"CAP_SYS_PACCT"},
727
+			},
728
+		},
729
+		{
730
+			LinuxSyscall: specs.LinuxSyscall{
731
+				Names: []string{
732
+					"kcmp",
733
+					"pidfd_getfd",
734
+					"process_madvise",
735
+					"process_vm_readv",
736
+					"process_vm_writev",
737
+					"ptrace",
738
+				},
739
+				Action: specs.ActAllow,
740
+			},
741
+			Includes: &Filter{
742
+				Caps: []string{"CAP_SYS_PTRACE"},
743
+			},
744
+		},
745
+		{
746
+			LinuxSyscall: specs.LinuxSyscall{
747
+				Names: []string{
748
+					"iopl",
749
+					"ioperm",
750
+				},
751
+				Action: specs.ActAllow,
752
+			},
753
+			Includes: &Filter{
754
+				Caps: []string{"CAP_SYS_RAWIO"},
755
+			},
756
+		},
757
+		{
758
+			LinuxSyscall: specs.LinuxSyscall{
759
+				Names: []string{
760
+					"settimeofday",
761
+					"stime",
762
+					"clock_settime",
763
+					"clock_settime64",
764
+				},
765
+				Action: specs.ActAllow,
766
+			},
767
+			Includes: &Filter{
768
+				Caps: []string{"CAP_SYS_TIME"},
769
+			},
770
+		},
771
+		{
772
+			LinuxSyscall: specs.LinuxSyscall{
773
+				Names: []string{
774
+					"vhangup",
775
+				},
776
+				Action: specs.ActAllow,
777
+			},
778
+			Includes: &Filter{
779
+				Caps: []string{"CAP_SYS_TTY_CONFIG"},
780
+			},
781
+		},
782
+		{
783
+			LinuxSyscall: specs.LinuxSyscall{
784
+				Names: []string{
785
+					"get_mempolicy",
786
+					"mbind",
787
+					"set_mempolicy",
788
+					"set_mempolicy_home_node", // kernel v5.17, libseccomp v2.5.4
789
+				},
790
+				Action: specs.ActAllow,
791
+			},
792
+			Includes: &Filter{
793
+				Caps: []string{"CAP_SYS_NICE"},
794
+			},
795
+		},
796
+		{
797
+			LinuxSyscall: specs.LinuxSyscall{
798
+				Names: []string{
799
+					"syslog",
800
+				},
801
+				Action: specs.ActAllow,
802
+			},
803
+			Includes: &Filter{
804
+				Caps: []string{"CAP_SYSLOG"},
805
+			},
806
+		},
807
+		{
808
+			LinuxSyscall: specs.LinuxSyscall{
809
+				Names: []string{
810
+					"bpf",
811
+				},
812
+				Action: specs.ActAllow,
813
+			},
814
+			Includes: &Filter{
815
+				Caps: []string{"CAP_BPF"},
816
+			},
817
+		},
818
+		{
819
+			LinuxSyscall: specs.LinuxSyscall{
820
+				Names: []string{
821
+					"perf_event_open",
822
+				},
823
+				Action: specs.ActAllow,
824
+			},
825
+			Includes: &Filter{
826
+				Caps: []string{"CAP_PERFMON"},
827
+			},
828
+		},
829
+	}
830
+
831
+	errnoRet := uint(unix.EPERM)
832
+	return &Seccomp{
833
+		LinuxSeccomp: specs.LinuxSeccomp{
834
+			DefaultAction:   specs.ActErrno,
835
+			DefaultErrnoRet: &errnoRet,
836
+		},
837
+		ArchMap:  arches(),
838
+		Syscalls: syscalls,
839
+	}
840
+}
0 841
new file mode 100644
... ...
@@ -0,0 +1,58 @@
0
+package seccomp
1
+
2
+import (
3
+	"fmt"
4
+	"sync"
5
+
6
+	"golang.org/x/sys/unix"
7
+)
8
+
9
+var (
10
+	currentKernelVersion *KernelVersion
11
+	kernelVersionError   error
12
+	once                 sync.Once
13
+)
14
+
15
+// getKernelVersion gets the current kernel version.
16
+func getKernelVersion() (*KernelVersion, error) {
17
+	once.Do(func() {
18
+		var uts unix.Utsname
19
+		if err := unix.Uname(&uts); err != nil {
20
+			return
21
+		}
22
+		// Remove the \x00 from the release for Atoi to parse correctly
23
+		currentKernelVersion, kernelVersionError = parseRelease(unix.ByteSliceToString(uts.Release[:]))
24
+	})
25
+	return currentKernelVersion, kernelVersionError
26
+}
27
+
28
+// parseRelease parses a string and creates a KernelVersion based on it.
29
+func parseRelease(release string) (*KernelVersion, error) {
30
+	version := KernelVersion{}
31
+
32
+	// We're only make sure we get the "kernel" and "major revision". Sometimes we have
33
+	// 3.12.25-gentoo, but sometimes we just have 3.12-1-amd64.
34
+	_, err := fmt.Sscanf(release, "%d.%d", &version.Kernel, &version.Major)
35
+	if err != nil {
36
+		return nil, fmt.Errorf("failed to parse kernel version %q: %w", release, err)
37
+	}
38
+	return &version, nil
39
+}
40
+
41
+// kernelGreaterEqualThan checks if the host's kernel version is greater than, or
42
+// equal to the given kernel version v. Only "kernel version" and "major revision"
43
+// can be specified (e.g., "3.12") and will be taken into account, which means
44
+// that 3.12.25-gentoo and 3.12-1-amd64 are considered equal (kernel: 3, major: 12).
45
+func kernelGreaterEqualThan(minVersion KernelVersion) (bool, error) {
46
+	kv, err := getKernelVersion()
47
+	if err != nil {
48
+		return false, err
49
+	}
50
+	if kv.Kernel > minVersion.Kernel {
51
+		return true, nil
52
+	}
53
+	if kv.Kernel == minVersion.Kernel && kv.Major >= minVersion.Major {
54
+		return true, nil
55
+	}
56
+	return false, nil
57
+}
0 58
new file mode 100644
... ...
@@ -0,0 +1,115 @@
0
+package seccomp
1
+
2
+import (
3
+	"encoding/json"
4
+	"fmt"
5
+	"strconv"
6
+	"strings"
7
+
8
+	"github.com/opencontainers/runtime-spec/specs-go"
9
+)
10
+
11
+// Seccomp represents the config for a seccomp profile for syscall restriction.
12
+// It is used to marshal/unmarshal the JSON profiles as accepted by docker, and
13
+// extends the runtime-spec's specs.LinuxSeccomp, overriding some fields to
14
+// provide the ability to define conditional rules based on the host's kernel
15
+// version, architecture, and the container's capabilities.
16
+type Seccomp struct {
17
+	specs.LinuxSeccomp
18
+
19
+	// ArchMap contains a list of Architectures and Sub-architectures for the
20
+	// profile. When generating the profile, this list is expanded to a
21
+	// []specs.Arch, to propagate the Architectures field of the profile.
22
+	ArchMap []Architecture `json:"archMap,omitempty"`
23
+
24
+	// Syscalls contains lists of syscall rules. Rules can define conditions
25
+	// for them to be included or excluded in the resulting profile (based on
26
+	// kernel version, architecture, capabilities, etc.). These lists are
27
+	// expanded to an specs.Syscall  When generating the profile, these lists
28
+	// are expanded to a []specs.LinuxSyscall.
29
+	Syscalls []*Syscall `json:"syscalls"`
30
+}
31
+
32
+// Architecture is used to represent a specific architecture
33
+// and its sub-architectures
34
+type Architecture struct {
35
+	Arch      specs.Arch   `json:"architecture"`
36
+	SubArches []specs.Arch `json:"subArchitectures"`
37
+}
38
+
39
+// Filter is used to conditionally apply Seccomp rules
40
+type Filter struct {
41
+	Caps   []string `json:"caps,omitempty"`
42
+	Arches []string `json:"arches,omitempty"`
43
+
44
+	// MinKernel describes the minimum kernel version the rule must be applied
45
+	// on, in the format "<kernel version>.<major revision>" (e.g. "3.12").
46
+	//
47
+	// When matching the kernel version of the host, minor revisions, and distro-
48
+	// specific suffixes are ignored, which means that "3.12.25-gentoo", "3.12-1-amd64",
49
+	// "3.12", and "3.12-rc5" are considered equal (kernel 3, major revision 12).
50
+	MinKernel *KernelVersion `json:"minKernel,omitempty"`
51
+}
52
+
53
+// Syscall is used to match a group of syscalls in Seccomp. It extends the
54
+// runtime-spec Syscall type, adding a "Name" field for backward compatibility
55
+// with older JSON representations, additional "Comment" metadata, and conditional
56
+// rules ("Includes", "Excludes") used to generate a runtime-spec Seccomp profile
57
+// based on the container (capabilities) and host's (arch, kernel) configuration.
58
+type Syscall struct {
59
+	specs.LinuxSyscall
60
+	// Deprecated: kept for backward compatibility with old JSON profiles, use Names instead
61
+	Name     string  `json:"name,omitempty"`
62
+	Comment  string  `json:"comment,omitempty"`
63
+	Includes *Filter `json:"includes,omitempty"`
64
+	Excludes *Filter `json:"excludes,omitempty"`
65
+}
66
+
67
+// KernelVersion holds information about the kernel.
68
+type KernelVersion struct {
69
+	Kernel uint64 // Version of the Kernel (i.e., the "4" in "4.1.2-generic")
70
+	Major  uint64 // Major revision of the Kernel (i.e., the "1" in "4.1.2-generic")
71
+}
72
+
73
+// String implements fmt.Stringer for KernelVersion
74
+func (k *KernelVersion) String() string {
75
+	if k.Kernel > 0 || k.Major > 0 {
76
+		return fmt.Sprintf("%d.%d", k.Kernel, k.Major)
77
+	}
78
+	return ""
79
+}
80
+
81
+// MarshalJSON implements json.Unmarshaler for KernelVersion
82
+func (k *KernelVersion) MarshalJSON() ([]byte, error) {
83
+	return json.Marshal(k.String())
84
+}
85
+
86
+// UnmarshalJSON implements json.Marshaler for KernelVersion
87
+func (k *KernelVersion) UnmarshalJSON(version []byte) error {
88
+	var (
89
+		ver string
90
+		err error
91
+	)
92
+
93
+	// make sure we have a string
94
+	if err = json.Unmarshal(version, &ver); err != nil {
95
+		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": %v`, string(version), err)
96
+	}
97
+	if ver == "" {
98
+		return nil
99
+	}
100
+	parts := strings.SplitN(ver, ".", 3)
101
+	if len(parts) != 2 {
102
+		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>"`, string(version))
103
+	}
104
+	if k.Kernel, err = strconv.ParseUint(parts[0], 10, 8); err != nil {
105
+		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": %v`, string(version), err)
106
+	}
107
+	if k.Major, err = strconv.ParseUint(parts[1], 10, 8); err != nil {
108
+		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": %v`, string(version), err)
109
+	}
110
+	if k.Kernel == 0 && k.Major == 0 {
111
+		return fmt.Errorf(`invalid kernel version: %s, expected "<kernel>.<major>": version cannot be 0.0`, string(version))
112
+	}
113
+	return nil
114
+}
0 115
new file mode 100644
... ...
@@ -0,0 +1,168 @@
0
+//go:generate go run -tags 'seccomp' generate.go
1
+
2
+package seccomp
3
+
4
+import (
5
+	"encoding/json"
6
+	"errors"
7
+	"fmt"
8
+	"runtime"
9
+
10
+	"github.com/opencontainers/runtime-spec/specs-go"
11
+)
12
+
13
+// GetDefaultProfile returns the default seccomp profile.
14
+func GetDefaultProfile(rs *specs.Spec) (*specs.LinuxSeccomp, error) {
15
+	return setupSeccomp(DefaultProfile(), rs)
16
+}
17
+
18
+// LoadProfile takes a json string and decodes the seccomp profile.
19
+func LoadProfile(body string, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
20
+	var config Seccomp
21
+	if err := json.Unmarshal([]byte(body), &config); err != nil {
22
+		return nil, fmt.Errorf("Decoding seccomp profile failed: %v", err)
23
+	}
24
+	return setupSeccomp(&config, rs)
25
+}
26
+
27
+// libseccomp string => seccomp arch
28
+var nativeToSeccomp = map[string]specs.Arch{
29
+	"x86":         specs.ArchX86,
30
+	"amd64":       specs.ArchX86_64,
31
+	"arm":         specs.ArchARM,
32
+	"arm64":       specs.ArchAARCH64,
33
+	"mips64":      specs.ArchMIPS64,
34
+	"mips64n32":   specs.ArchMIPS64N32,
35
+	"mipsel64":    specs.ArchMIPSEL64,
36
+	"mips3l64n32": specs.ArchMIPSEL64N32,
37
+	"mipsle":      specs.ArchMIPSEL,
38
+	"ppc":         specs.ArchPPC,
39
+	"ppc64":       specs.ArchPPC64,
40
+	"ppc64le":     specs.ArchPPC64LE,
41
+	"riscv64":     specs.ArchRISCV64,
42
+	"s390":        specs.ArchS390,
43
+	"s390x":       specs.ArchS390X,
44
+}
45
+
46
+// GOARCH => libseccomp string
47
+var goToNative = map[string]string{
48
+	"386":         "x86",
49
+	"amd64":       "amd64",
50
+	"arm":         "arm",
51
+	"arm64":       "arm64",
52
+	"mips64":      "mips64",
53
+	"mips64p32":   "mips64n32",
54
+	"mips64le":    "mipsel64",
55
+	"mips64p32le": "mips3l64n32",
56
+	"mipsle":      "mipsel",
57
+	"ppc":         "ppc",
58
+	"ppc64":       "ppc64",
59
+	"ppc64le":     "ppc64le",
60
+	"riscv64":     "riscv64",
61
+	"s390":        "s390",
62
+	"s390x":       "s390x",
63
+}
64
+
65
+// inSlice tests whether a string is contained in a slice of strings or not.
66
+// Comparison is case sensitive
67
+func inSlice(slice []string, s string) bool {
68
+	for _, ss := range slice {
69
+		if s == ss {
70
+			return true
71
+		}
72
+	}
73
+	return false
74
+}
75
+
76
+func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
77
+	if config == nil {
78
+		return nil, nil
79
+	}
80
+
81
+	// No default action specified, no syscalls listed, assume seccomp disabled
82
+	if config.DefaultAction == "" && len(config.Syscalls) == 0 {
83
+		return nil, nil
84
+	}
85
+
86
+	if len(config.Architectures) != 0 && len(config.ArchMap) != 0 {
87
+		return nil, errors.New("both 'architectures' and 'archMap' are specified in the seccomp profile, use either 'architectures' or 'archMap'")
88
+	}
89
+
90
+	if len(config.LinuxSeccomp.Syscalls) != 0 {
91
+		// The Seccomp type overrides the LinuxSeccomp.Syscalls field,
92
+		// so 'this should never happen' when loaded from JSON, but could
93
+		// happen if someone constructs the Config from source.
94
+		return nil, errors.New("the LinuxSeccomp.Syscalls field should be empty")
95
+	}
96
+
97
+	var (
98
+		// Copy all common / standard properties to the output profile
99
+		newConfig = &config.LinuxSeccomp
100
+		arch      = goToNative[runtime.GOARCH]
101
+	)
102
+	if seccompArch, ok := nativeToSeccomp[arch]; ok {
103
+		for _, a := range config.ArchMap {
104
+			if a.Arch == seccompArch {
105
+				newConfig.Architectures = append(newConfig.Architectures, a.Arch)
106
+				newConfig.Architectures = append(newConfig.Architectures, a.SubArches...)
107
+				break
108
+			}
109
+		}
110
+	}
111
+
112
+Loop:
113
+	// Convert Syscall to OCI runtimes-spec specs.LinuxSyscall after filtering them.
114
+	for _, call := range config.Syscalls {
115
+		if call.Name != "" {
116
+			if len(call.Names) != 0 {
117
+				return nil, errors.New("both 'name' and 'names' are specified in the seccomp profile, use either 'name' or 'names'")
118
+			}
119
+			call.Names = []string{call.Name}
120
+		}
121
+		if call.Excludes != nil {
122
+			if len(call.Excludes.Arches) > 0 {
123
+				if inSlice(call.Excludes.Arches, arch) {
124
+					continue Loop
125
+				}
126
+			}
127
+			if len(call.Excludes.Caps) > 0 {
128
+				for _, c := range call.Excludes.Caps {
129
+					if inSlice(rs.Process.Capabilities.Bounding, c) {
130
+						continue Loop
131
+					}
132
+				}
133
+			}
134
+			if call.Excludes.MinKernel != nil {
135
+				if ok, err := kernelGreaterEqualThan(*call.Excludes.MinKernel); err != nil {
136
+					return nil, err
137
+				} else if ok {
138
+					continue Loop
139
+				}
140
+			}
141
+		}
142
+		if call.Includes != nil {
143
+			if len(call.Includes.Arches) > 0 {
144
+				if !inSlice(call.Includes.Arches, arch) {
145
+					continue Loop
146
+				}
147
+			}
148
+			if len(call.Includes.Caps) > 0 {
149
+				for _, c := range call.Includes.Caps {
150
+					if !inSlice(rs.Process.Capabilities.Bounding, c) {
151
+						continue Loop
152
+					}
153
+				}
154
+			}
155
+			if call.Includes.MinKernel != nil {
156
+				if ok, err := kernelGreaterEqualThan(*call.Includes.MinKernel); err != nil {
157
+					return nil, err
158
+				} else if !ok {
159
+					continue Loop
160
+				}
161
+			}
162
+		}
163
+		newConfig.Syscalls = append(newConfig.Syscalls, call.LinuxSyscall)
164
+	}
165
+
166
+	return newConfig, nil
167
+}
... ...
@@ -970,6 +970,12 @@ github.com/moby/moby/client
970 970
 ## explicit; go 1.19
971 971
 github.com/moby/patternmatcher
972 972
 github.com/moby/patternmatcher/ignorefile
973
+# github.com/moby/profiles/apparmor v0.1.0
974
+## explicit; go 1.23.0
975
+github.com/moby/profiles/apparmor
976
+# github.com/moby/profiles/seccomp v0.1.0
977
+## explicit; go 1.23.0
978
+github.com/moby/profiles/seccomp
973 979
 # github.com/moby/pubsub v1.0.0
974 980
 ## explicit; go 1.19
975 981
 github.com/moby/pubsub