Skip to content

Commit

Permalink
seccomp: add support for defaultErrnoRet
Browse files Browse the repository at this point in the history
Add support to specify the default errno return value.

The OCI runtime specs already have support for it, and both crun (>=
0.19) and runc (>= 1.0-rc95) have support for it.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jun 14, 2021
1 parent f3122e8 commit adee333
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/seccomp/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func specToSeccomp(spec *specs.LinuxSeccomp) (*Seccomp, error) {
return nil, errors.Wrap(err, "convert default action")
}
res.DefaultAction = newDefaultAction
res.DefaultErrnoRet = spec.DefaultErrnoRet

// Loop through all syscall blocks and convert them to the internal format
for _, call := range spec.Syscalls {
Expand Down
2 changes: 1 addition & 1 deletion pkg/seccomp/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func BuildFilter(spec *specs.LinuxSeccomp) (*libseccomp.ScmpFilter, error) {
return nil, errors.Wrap(err, "convert spec to seccomp profile")
}

defaultAction, err := toAction(profile.DefaultAction, nil)
defaultAction, err := toAction(profile.DefaultAction, profile.DefaultErrnoRet)
if err != nil {
return nil, errors.Wrapf(err, "convert default action %s", profile.DefaultAction)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/seccomp/seccomp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error)
}

newConfig.DefaultAction = specs.LinuxSeccompAction(config.DefaultAction)
newConfig.DefaultErrnoRet = config.DefaultErrnoRet

Loop:
// Loop through all syscall blocks and convert them to libcontainer format after filtering them
Expand Down
3 changes: 2 additions & 1 deletion pkg/seccomp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package seccomp

// Seccomp represents the config for a seccomp profile for syscall restriction.
type Seccomp struct {
DefaultAction Action `json:"defaultAction"`
DefaultAction Action `json:"defaultAction"`
DefaultErrnoRet *uint `json:"defaultErrnoRet"`
// Architectures is kept to maintain backward compatibility with the old
// seccomp profile.
Architectures []Arch `json:"architectures,omitempty"`
Expand Down

0 comments on commit adee333

Please sign in to comment.