Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SCMP_ACT_TRACE as a valid Seccomp action #347

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libcontainer/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ type Seccomp struct {
type Action int

const (
Kill Action = iota - 4
Kill Action = iota - 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not do it like this ?


const (
    Kill Action = iota
    Errno
    Trap
    Allow
    Trace
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way, uninitialized Action variables will not be a valid constant, and will cause an error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just like the define of "EqualTo Operator", I do think it has problem,Maybe the error caused by other. It doesn't matter all the same,just a surgestion. thanks for your reply.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't iota -1 do the same thing?

Errno
Trap
Trace
Allow
)

Expand Down
2 changes: 2 additions & 0 deletions libcontainer/seccomp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func ConvertStringToAction(in string) (configs.Action, error) {
return configs.Trap, nil
case "SCMP_ACT_ALLOW":
return configs.Allow, nil
case "SCMP_ACT_TRACE":
return configs.Trace, nil
default:
return 0, fmt.Errorf("string %s is not a valid action for seccomp", in)
}
Expand Down
3 changes: 3 additions & 0 deletions libcontainer/seccomp/seccomp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
actAllow = libseccomp.ActAllow
actTrap = libseccomp.ActTrap
actKill = libseccomp.ActKill
actTrace = libseccomp.ActTrace.SetReturnCode(int16(syscall.EPERM))
actErrno = libseccomp.ActErrno.SetReturnCode(int16(syscall.EPERM))
)

Expand Down Expand Up @@ -81,6 +82,8 @@ func getAction(act configs.Action) (libseccomp.ScmpAction, error) {
return actErrno, nil
case configs.Trap:
return actTrap, nil
case configs.Trace:
return actTrace, nil
case configs.Allow:
return actAllow, nil
default:
Expand Down