Skip to content

Commit

Permalink
seccomp: allow to override default errno return code
Browse files Browse the repository at this point in the history
the specs already support overriding the errno code for the syscalls
but the default value is hardcoded to EPERM.

Add a new attribute to override the default value.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Feb 22, 2021
1 parent ec964df commit f7ef278
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions config-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ The actions, architectures, and operators are strings that match the definitions
The following parameters can be specified to set up seccomp:

* **`defaultAction`** *(string, REQUIRED)* - the default action for seccomp. Allowed values are the same as `syscalls[].action`.
* **`defaultErrnoRet`** *(uint, OPTIONAL)* - the errno return code to use.
Some actions like `SCMP_ACT_ERRNO` and `SCMP_ACT_TRACE` allow to specify the errno code to return.
When the action doesn't support an errno, the runtime MUST print and error and fail.
If not specified then its default value is `EPERM`.
* **`architectures`** *(array of strings, OPTIONAL)* - the architecture used for system calls.
A valid list of constants as of libseccomp v2.5.0 is shown below.

Expand Down
3 changes: 3 additions & 0 deletions schema/config-linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@
"defaultAction": {
"$ref": "defs-linux.json#/definitions/SeccompAction"
},
"defaultErrnoRet": {
"$ref": "defs.json#/definitions/uint32"
},
"flags": {
"type": "array",
"items": {
Expand Down
9 changes: 5 additions & 4 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,11 @@ type VMImage struct {

// LinuxSeccomp represents syscall restrictions
type LinuxSeccomp struct {
DefaultAction LinuxSeccompAction `json:"defaultAction"`
Architectures []Arch `json:"architectures,omitempty"`
Flags []LinuxSeccompFlag `json:"flags,omitempty"`
Syscalls []LinuxSyscall `json:"syscalls,omitempty"`
DefaultAction LinuxSeccompAction `json:"defaultAction"`
DefaultErrnoRet *uint `json:"defaultErrnoRet,omitempty"`
Architectures []Arch `json:"architectures,omitempty"`
Flags []LinuxSeccompFlag `json:"flags,omitempty"`
Syscalls []LinuxSyscall `json:"syscalls,omitempty"`
}

// Arch used for additional architectures
Expand Down

0 comments on commit f7ef278

Please sign in to comment.