-
Notifications
You must be signed in to change notification settings - Fork 113
Makefile: Build agent with tag seccomp to support seccomp #353
Conversation
Hi @nitkon - thanks for raising! The CI's are failing:
The problem is that https://github.com/kata-containers/tests/blob/master/.ci/install_kata_image.sh is building a new image using this PR, but the (Clear Linux) mini-os doesn't provide that library by default. As such, I think you'll need to add seccomp support to the images in osbuilder before this will pass: |
Makefile
Outdated
@@ -31,6 +31,7 @@ COMMIT_NO_SHORT := $(shell git rev-parse --short HEAD 2> /dev/null || true) | |||
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO}) | |||
VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION)) | |||
ARCH := $(shell go env GOARCH) | |||
BUILDTAGS := seccomp |
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.
It might be useful to build the agent without seccomp (but make it the default) so maybe you could add support for WITH_SECCOMP=no
or something.
It might also be good to add the fact that the agent has been build with seccomp support to the announce fields that are logged on agent startup:
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.
@jodh-intel : Why would it be useful to have seccomp support optional, whats the usecase to turn it off ?
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.
Don't get me wrong - I'd like it enabled :)
But some folk may not want it and be happy to use a system like the current one without having to hack the makefiles and osbuilder scripts. It would help to know the performance and memory density impact of using seccomp.
/cc @grahamwhaley.
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.
Indeed, I think we should at least assess if there is any density (footprint) or boot speed impact.
You could try using https://github.com/kata-containers/tests/tree/master/metrics/report to do a before/after comparison to see if there is any measurable (and repeatable) difference.
If there is, then maybe we will discuss having two agent versions.
If there is not, we would probably just go ahead and enable it.
(traditionally we have just moved ahead and enabled things, but that does mean over time we suffer 'death of a thousand cuts' and our footprint and boot speed slowly creeps up and up.... we should make these conscious decisions ;-) )
Hi @jodh-intel , |
Thanks @nitkon. |
I am running the tests with and without the seccomp PR on my local machine. The second time the tests are running painfully slow(running since 3 hours), will update the results. @grahamwhaley @jodh-intel
|
@nitkon ouch! That boot time test just launches
Is it the seccomp version that is running slow? (that is of course my presumption). May be worth a quick test from the commandline something like: $ time docker run --rm -ti --runtime=kata-runtime ubuntu uname -a and seeing if that has a large run/quit time for instance. Then we can diagnose from there. |
"security through inactivity" :-) |
On the contrary, since I already had the patch applied I ran those tests quickly, generated the *json files and then was trying without my patch and with an initrd image without seccomp support when it became slow! |
:-) thanks for the confirmation @nitkon - we should try and figure out what is causing it. The only time in the past when I have seen huge slowdowns on tests is either:
|
@grahamwhaley : I am running on my x86 laptop as I do not have a x86 server, with 8gb RAM and a little space on hard disk. Probably that's the reason the tests are running very slow. |
Ah, pretty small machine @nitkon ;-) Over in kata-containers/tests#650 I added the ability to just run subsets of tests to the grabdata.sh (the PR is not merged yet). You could then narrow to density ( |
@grahamwhaley @jodh-intel : Its slowing my system in my second attempt as well. Meanwhile, I will check to see how to run lesser number of tests. However, if anyone has access to the x86 server, can they run and check the memory/boot footprint? @ydjain ? |
@jodh-intel @grahamwhaley : Here is the metrics report generated. Thanks to @ydjainopensource for running the tests on his 16gb x86 machine. |
@nitkon @ydjainopensource - thanks for the report!
Looking at the last page, there is no 'image version' listed - would you happen to be running with an I'll see if I can get to try and re-create this later on - something needs debugging, quite possibly in the report generation (maybe there are assumptions that will not be true for all users etc.). I guess I should note also, that the reportgen grabdata should be run on a 'quiet' system - that is, don't run it in the background and carry on doing other stuff - as that will potentially throw out the results. |
Will turning swap off and rerunning the tests solve this issue? |
Hi @ydjainopensource I guess we need to make a note on the report docs that ideally the test would be run on a fresh clean system every time. Let me know if you're able to do the runs again. I'll let you know if I find a slot (but I don't generally have an initrd set up, so that's going to take me a little bit to get going as well). |
@grahamwhaley No issues. I will reboot my system and try running the tests again later today. |
i have retried running the script here are the results. |
Thanks @ydjainopensource - much appreciated.
I think that has given us the data to:
|
@grahamwhaley those numbers are pretty high and they're not fitting the current trend where we try to optimize and improve boot time and footprint. Can we discuss the importance of seccomp support? I think a drop in performances can only be acceptable if the security is obviously improved. |
So what's the conclusion here? Would seccomp not be enabled by default? /cc @sboeuf @grahamwhaley @jodh-intel |
@nitkon I think we should add seccomp however, we don't make it the default. As suggested by you, if someone wants he exports a global and rebuilds runtime/agent/osbuilder and he's good to go. This would neither add unnecessary performance penalties nor degrade security. As for testing, as noted by @jcvenegas here, we have a very busy CI today, so testing every build with/without seccomp sounds unresonable. Instead we just test it while making a release. WDYT? |
Codecov Report
@@ Coverage Diff @@
## master #353 +/- ##
==========================================
+ Coverage 47.21% 47.22% +0.01%
==========================================
Files 15 15
Lines 2442 2471 +29
==========================================
+ Hits 1153 1167 +14
- Misses 1140 1154 +14
- Partials 149 150 +1 |
Updated my PR. Also look at osbuilder PR too. |
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.
LGTM.
Just a small question, shouldn't we include individual file changes into it too? I mean it makes more sense for someone viewing the history to know all the files changed for adding seccomp support. WDYT @jodh-intel ?
If seccomp is not supported, I think this should be well documented in the current limitations. I agree that running in a VM makes seccomp a bit less important, but still the user should be well aware of the limitation. Also WDYT about documenting how to enable seccomp support in documentation? Cause this somehow affects:
|
If someone wants to pick up the limitations aspect of this... |
Hi @jodh-intel, I shall be picking this up. Will send a PR soon. |
Thanks @nitkon! 😄 |
@@ -31,6 +31,9 @@ COMMIT_NO_SHORT := $(shell git rev-parse --short HEAD 2> /dev/null || true) | |||
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO}) | |||
VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION)) | |||
ARCH := $(shell go env GOARCH) | |||
ifeq ($(SECCOMP),yes) | |||
BUILDTAGS := seccomp | |||
endif |
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.
The same way we have INIT := no
by default, please make sure we have SECCOMP := no
too.
This way, we can merge this PR, but leaving the default way of building the agent the way it is.
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.
@jodh-intel @sboeuf : Sorry, I didn't understand the comment completely.
- When SECCOMP=yes will be passed when making a local rootfs image, If we use
SECCOMP := no
in this Makefile, just like INIT, it shall override its value, thus having no effect of environment variable passed. - We can set SECCOMP to no only if it's not set, but then still agent would be built the same way
go build -tags "" -o kata-agent -ldflags "-X main.version=1.2.0-5765593309eab087598c093ff226500af158df9c-dirty"
ifeq ($(SECCOMP),)
SECCOMP := no
endif
Probably I am missing something.
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.
Actually, I'm a bit confused now too as your code will work as we want currently.
I think @sboeuf might simply be suggesting that for consistency with the INIT
option that you supplement your change with an explicit:
# Set to 'yes' to build agent with seccomp support
SECCOMP := no
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.
@jodh-intel : If I set SECCOMP := no
in the Makefile like INIT
it would over-ride what was passed by the user as an environment variable when building the rootfs.
Probably this is what he means? To set it to "no" if not set by the user?
https://github.com/kata-containers/osbuilder/blob/93ad0491ef6d3d0b9d20956071b6b39d0a787b4d/rootfs-builder/rootfs.sh#L16
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.
@nitkon: variables passed from command line have priority over definitions inside Makefiles: https://www.gnu.org/software/make/manual/make.html#Override-Directive
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.
@marcov : Oh I was thinking the other way round. Now it makes sense. Update my PR. :-D
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.
The only time this won't work is if the user wants to enable seccomp and tries to flag that by setting an actual environment variable:
$ export SECCOMP="yes"
$ make # SECCOMP will still be "no" 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.
@jodh-intel: Yea, I had tried it the same way as you mentioned and so thought it to be the other way round. :-)
Inorder to get runc/libcontainer/seccomp/seccomp_linux.go built in, build agent with seccomp tag. Fixes: #104 Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com
Inorder to get runc/libcontainer/seccomp/seccomp_linux.go
built in, build agent with seccomp tag.
Fixes: #104
Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com