Skip to content

Commit 83e5943

Browse files
author
Mrunal Patel
committed
Merge pull request #200 from mheon/seccomp_architecture
Add Architecture field to Seccomp configuration in Linux runtime
2 parents 96bcd04 + 215d0d9 commit 83e5943

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

runtime-config-linux.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,44 @@ For more information about Apparmor, see [Apparmor documentation](https://wiki.u
319319
Seccomp provides application sandboxing mechanism in the Linux kernel.
320320
Seccomp configuration allows one to configure actions to take for matched syscalls and furthermore also allows matching on values passed as arguments to syscalls.
321321
For more information about Seccomp, see [Seccomp kernel documentation](https://www.kernel.org/doc/Documentation/prctl/seccomp_filter.txt)
322-
The actions and operators are strings that match the definitions in seccomp.h from [libseccomp](https://github.com/seccomp/libseccomp) and are translated to corresponding values.
322+
The actions, architectures, and operators are strings that match the definitions in seccomp.h from [libseccomp](https://github.com/seccomp/libseccomp) and are translated to corresponding values.
323+
A valid list of constants as of Libseccomp v2.2.3 is contained below.
324+
325+
Architecture Constants
326+
* `SCMP_ARCH_X86`
327+
* `SCMP_ARCH_X86_64`
328+
* `SCMP_ARCH_X32`
329+
* `SCMP_ARCH_ARM`
330+
* `SCMP_ARCH_AARCH64`
331+
* `SCMP_ARCH_MIPS`
332+
* `SCMP_ARCH_MIPS64`
333+
* `SCMP_ARCH_MIPS64N32`
334+
* `SCMP_ARCH_MIPSEL`
335+
* `SCMP_ARCH_MIPSEL64`
336+
* `SCMP_ARCH_MIPSEL64N32`
337+
338+
Action Constants:
339+
* `SCMP_ACT_KILL`
340+
* `SCMP_ACT_TRAP`
341+
* `SCMP_ACT_ERRNO`
342+
* `SCMP_ACT_TRACE`
343+
* `SCMP_ACT_ALLOW`
344+
345+
Operator Constants:
346+
* `SCMP_CMP_NE`
347+
* `SCMP_CMP_LT`
348+
* `SCMP_CMP_LE`
349+
* `SCMP_CMP_EQ`
350+
* `SCMP_CMP_GE`
351+
* `SCMP_CMP_GT`
352+
* `SCMP_CMP_MASKED_EQ`
323353

324354
```json
325355
"seccomp": {
326356
"defaultAction": "SCMP_ACT_ALLOW",
357+
"architectures": [
358+
"SCMP_ARCH_X86"
359+
],
327360
"syscalls": [
328361
{
329362
"name": "getcwd",

runtime_config_linux.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,52 @@ type Device struct {
235235
// Seccomp represents syscall restrictions
236236
type Seccomp struct {
237237
DefaultAction Action `json:"defaultAction"`
238+
Architectures []Arch `json:"architectures"`
238239
Syscalls []*Syscall `json:"syscalls"`
239240
}
240241

242+
// Additional architectures permitted to be used for system calls
243+
// By default only the native architecture of the kernel is permitted
244+
type Arch string
245+
246+
const (
247+
ArchX86 Arch = "SCMP_ARCH_X86"
248+
ArchX86_64 Arch = "SCMP_ARCH_X86_64"
249+
ArchX32 Arch = "SCMP_ARCH_X32"
250+
ArchARM Arch = "SCMP_ARCH_ARM"
251+
ArchAARCH64 Arch = "SCMP_ARCH_AARCH64"
252+
ArchMIPS Arch = "SCMP_ARCH_MIPS"
253+
ArchMIPS64 Arch = "SCMP_ARCH_MIPS64"
254+
ArchMIPS64N32 Arch = "SCMP_ARCH_MIPS64N32"
255+
ArchMIPSEL Arch = "SCMP_ARCH_MIPSEL"
256+
ArchMIPSEL64 Arch = "SCMP_ARCH_MIPSEL64"
257+
ArchMIPSEL64N32 Arch = "SCMP_ARCH_MIPSEL64N32"
258+
)
259+
241260
// Action taken upon Seccomp rule match
242261
type Action string
243262

263+
const (
264+
ActKill Action = "SCMP_ACT_KILL"
265+
ActTrap Action = "SCMP_ACT_TRAP"
266+
ActErrno Action = "SCMP_ACT_ERRNO"
267+
ActTrace Action = "SCMP_ACT_TRACE"
268+
ActAllow Action = "SCMP_ACT_ALLOW"
269+
)
270+
244271
// Operator used to match syscall arguments in Seccomp
245272
type Operator string
246273

274+
const (
275+
OpNotEqual Operator = "SCMP_CMP_NE"
276+
OpLessThan Operator = "SCMP_CMP_LT"
277+
OpLessEqual Operator = "SCMP_CMP_LE"
278+
OpEqualTo Operator = "SCMP_CMP_EQ"
279+
OpGreaterEqual Operator = "SCMP_CMP_GE"
280+
OpGreaterThan Operator = "SCMP_CMP_GT"
281+
OpMaskedEqual Operator = "SCMP_CMP_MASKED_EQ"
282+
)
283+
247284
// Arg used for matching specific syscall arguments in Seccomp
248285
type Arg struct {
249286
Index uint `json:"index"`

0 commit comments

Comments
 (0)