-
Notifications
You must be signed in to change notification settings - Fork 143
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
Use seccomp library for adding seccomp configuration flags #159
Use seccomp library for adding seccomp configuration flags #159
Conversation
|
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
func setupSpec(g *generate.Generator, context *cli.Context) error { | ||
func setupSpec(g generate.Generator, context *cli.Context) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing the pointer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They just landed via #138.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, Must have accidentally cut it when making the new branch. Thanks for the call out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wking Fixed
dfe2722 → cfb6d90 talks about rebasing, and pulls in some recent $ git log --graph --oneline --decorate origin/pr/159 | head -n4
You probably intended to rebase onto the current master. |
@wking Cleaning up now |
On Tue, Aug 02, 2016 at 12:55:58PM -0700, Grant Seltzer Richman wrote:
cfb6d90 → a9b3569 looks like it rebases onto master and then merges $ git glog a9b3569 | head -n7
The difference between a116901 and a9b3569 is that the latter removes
What you probably wanted to do instead was use a --force push in (2) So I think you want to recover with something like: $ git checkout add-seccomp-cli-features |
@wking Wow thank you very much, My git skills have much improving to be done, I appreciate your help! (Looking into build error right now) |
} | ||
|
||
return nil | ||
err := addSeccomp(g, context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass context first
@mrunalp PTAL |
const ( | ||
seccompOverwrite = "overwrite" | ||
seccompAppend = "append" | ||
nothing = "nothing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to run gofmt on this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I think this looks fine overall. @hmeng-19 Could you test/review as well? |
@grantseltzer , |
seccompArch := context.String("seccomp-arch") | ||
architectureArgs := strings.Split(seccompArch, ",") | ||
for _, arg := range architectureArgs { | ||
err = g.SetSeccompArchitecture(arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grantseltzer , it is not a real problem. But I believe you want to err := ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, what difference does it make in this context? Both appear to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works when you declare err
before using var err error
or err := ....
.
I pointed out because all the other for loops in this function seem to declare its own err
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, let's change this to err :=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
Ok that works for me. |
Should be part of default Sent from my iPhone
|
Part of default. |
A default seccomp config is now a part of the output of The |
I just tried this out and the runtime tests fail:
|
Which test is that? I can't reproduce that. I think what could be happening is there's a system call not in the white-list that is falling under the default action to |
I've added the syscalls to the default whitelist based on allowed capabilities, pretty sure that was the issue. |
@mrunalp PTAL |
return a, nil | ||
} | ||
|
||
//ParseDefaultAction simply sets the default action of the seccomp configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after //
From my testing:
I still see the default seccomp options with getcwd being allowed. |
Next I tried to use a template with no syscalls set.
|
For anyone else involved, based on my discussion with @mrunalp There's a check that will error out if a syscall rule is specified that has the same action as the defaultAction (I've added an error message instead of it failing silently). I'm going to be adding a The other edge case that needed to be addressed is when a new default action is specified but there are already system calls that match it. This should cause an error and to report the system calls that have this matching action. |
@grantseltzer For changing the default action, we should add a force flag in the API, so it clears syscalls that match the new action. |
@mrunalp Right, got it. |
Regardless, I've added flags for removing specific syscall rules or just all of them. I've also added a force option for setting the default action without it deleting rules that already have the same action set. |
LGTM |
cli.StringFlag{Name: "seccomp-trace", Usage: "specifies syscalls to respond with trace"}, | ||
cli.StringFlag{Name: "seccomp-kill", Usage: "specifies syscalls to respond with kill"}, | ||
cli.StringFlag{Name: "seccomp-remove", Usage: "specifies syscalls to remove seccomp rules for"}, | ||
cli.BoolFlag{Name: "seccomp-remove-all", Usage: "removes all syscall rules from seccomp configuration"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the options should be in sorted list as #204 does. So we don't need to do it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and reordered it. While not in strict alphabetical order, I separated it logically so that the syscall action flags were together (and alphabetical), the default flags together, etc...
I think the way it is now makes the most sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal opinion, separating them logically does not make too much sense. As seccomp related options all start with seccomp-*
, easily to see they are in one group and find the needed one.
I think Following one standard(alphabetical order) makes more sense.
@wking @mrunalp @liangchenye any comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can concede that. Will fix now Fixed
@@ -73,7 +80,6 @@ var generateFlags = []cli.Flag{ | |||
cli.Uint64Flag{Name: "linux-mem-kernel-limit", Usage: "kernel memory limit (in bytes)"}, | |||
cli.Uint64Flag{Name: "linux-mem-kernel-tcp", Usage: "kernel memory limit for tcp (in bytes)"}, | |||
cli.Uint64Flag{Name: "linux-mem-swappiness", Usage: "how aggressive the kernel will swap memory pages (Range from 0 to 100)"}, | |||
cli.Int64Flag{Name: "linux-pids-limit", Usage: "maximum number of PIDs"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need rebased
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, Thanks for catching that!
@grantseltzer can you add new options to |
Sure no problem @Mashimiao All fixed up, that reminded me to update the man page as well. On Oct 12, 2016 10:06 PM, "Ma Shimiao" notifications@github.com wrote:
|
@Mashimiao Does this look fine to you now? |
Though there are some minimal issues(like part of new options not in alpha order in man), almost looks good. |
Signed-off-by: Grantseltzer <grantseltzer@gmail.com> Signed-off-by: grantseltzer <grantseltzer@gmail.com>
@Mashimiao Just fixed the man page order |
Thanks. |
LGTM |
Thanks for the merge! On Oct 17, 2016 1:43 PM, "Mrunal Patel" notifications@github.com wrote:
|
I added functionality to specify syscalls and their arguments for all actions. Also changed default action and archs flags to ociseccompgen library.
Now we can do things like:
ocitools generate --seccomp-errno clone,write --seccomp-trace getcwd --seccomp-trap umount:0:1:2:NE
The behavior mimics that of: https://github.com/GrantSeltzer/Manhattan
Also updated man page to reflect this change.
Signed-off-by: Grantseltzer grantseltzer@gmail.com