Skip to content

Commit adee333

Browse files
committed
seccomp: add support for defaultErrnoRet
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 <gscrivan@redhat.com>
1 parent f3122e8 commit adee333

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

pkg/seccomp/conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func specToSeccomp(spec *specs.LinuxSeccomp) (*Seccomp, error) {
118118
return nil, errors.Wrap(err, "convert default action")
119119
}
120120
res.DefaultAction = newDefaultAction
121+
res.DefaultErrnoRet = spec.DefaultErrnoRet
121122

122123
// Loop through all syscall blocks and convert them to the internal format
123124
for _, call := range spec.Syscalls {

pkg/seccomp/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func BuildFilter(spec *specs.LinuxSeccomp) (*libseccomp.ScmpFilter, error) {
4141
return nil, errors.Wrap(err, "convert spec to seccomp profile")
4242
}
4343

44-
defaultAction, err := toAction(profile.DefaultAction, nil)
44+
defaultAction, err := toAction(profile.DefaultAction, profile.DefaultErrnoRet)
4545
if err != nil {
4646
return nil, errors.Wrapf(err, "convert default action %s", profile.DefaultAction)
4747
}

pkg/seccomp/seccomp_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error)
111111
}
112112

113113
newConfig.DefaultAction = specs.LinuxSeccompAction(config.DefaultAction)
114+
newConfig.DefaultErrnoRet = config.DefaultErrnoRet
114115

115116
Loop:
116117
// Loop through all syscall blocks and convert them to libcontainer format after filtering them

pkg/seccomp/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package seccomp
66

77
// Seccomp represents the config for a seccomp profile for syscall restriction.
88
type Seccomp struct {
9-
DefaultAction Action `json:"defaultAction"`
9+
DefaultAction Action `json:"defaultAction"`
10+
DefaultErrnoRet *uint `json:"defaultErrnoRet"`
1011
// Architectures is kept to maintain backward compatibility with the old
1112
// seccomp profile.
1213
Architectures []Arch `json:"architectures,omitempty"`

0 commit comments

Comments
 (0)