Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

rootfs: Conditionally add libseccomp support in rootfs image#156

Merged
egernst merged 2 commits intokata-containers:masterfrom
nitkon:master
Nov 12, 2018
Merged

rootfs: Conditionally add libseccomp support in rootfs image#156
egernst merged 2 commits intokata-containers:masterfrom
nitkon:master

Conversation

@nitkon
Copy link
Copy Markdown
Contributor

@nitkon nitkon commented Sep 5, 2018

If the rootfs is built with SECCOMP=yes environment
variable then include libseccomp package inside the
rootfs image. Else do not include it.

Fixes: #155

Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com

@@ -16,3 +16,4 @@ MIRROR=http://dl-5.alpinelinux.org/alpine
# Mandatory Packages that must be installed
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did you forget to include ubuntu?

@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Sep 6, 2018

@ydjainopensource : @jodh-intel : Updated my PR

# Mandatory Packages that must be installed
# - iptables: Need by Kata agent
PACKAGES="iptables"
[ "$SECCOMP" == "yes" ] && PACKAGES+=" libseccomp" || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't actually need the || true here so you can simplify to the following (note the single equals too):

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jodh-intel : Updated!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jodh-intel : I guess your comments apply here as well

[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true

Another PR to optimize it?
If I am right, the purpose of adding || true is to tell set -e in the script its ok to fail here and not error out and stop.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That is what || true is for, yes. But that test won't ever "fail" - it just won't match so set -e will not exit if "$AGENT_INIT" != "no".

You could fix that on a separate commit on this PR if you want rather than creating a whole new PR for it ;)

@jodh-intel
Copy link
Copy Markdown

lgtm

# systemd: An init system that will start kata-agent if kata-agent
# itself is not configured as init process.
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
[ "$AGENT_INIT" = "no" ] && PACKAGES+=" systemd"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

seccomp for Euler OS?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

@nitkon nitkon Sep 6, 2018

Choose a reason for hiding this comment

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

@ydjainopensource: I am not sure what the package name for libseccomp and libseccomp-devel is, in Euler OS.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lools like it's just libseccomp (https://developer.huawei.com/ict/site-euleros/euleros/repo/yum/2.3/os/x86_64/Packages), but let's get an ack from @liangchenye.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jodh-intel : Have updated my PR earlier according to the package name mentioned in the above-mentioned link by you.
cc @liangchenye

@jcvenegas
Copy link
Copy Markdown
Member

@nitkon to avoid have possible image fragmentation I wonder if there is any big impact have just installed libseccomp but not used if not required.

@jodh-intel
Copy link
Copy Markdown

@jcvenegas - the installed size of the seccomp package (for EulerOS) is ~200k fwics. The trouble is, if we add this to the default images we might end up setting a precedent and end up with @grahamwhaley's "death by a thousand cuts" where we keep on adding more and more small packages which results in a big increase in image size.

Suggestion (sorry about the huge letters folks! :)

How about this: We introduce a policy where we will add "security-related" packages to the default image only. But everything else would have to be conditional? That could still "bite" us if a particular security package is "large" but we can deal with such situations as they arise.

Determining what's in an image

It's worth reminding ourselves that -- conditional or not -- tools like https://github.com/kata-containers/runtime/blob/master/data/kata-collect-data.sh.in will still be able to show the difference between images due to osbuilder creating /var/lib/osbuilder/osbuilder.yaml.

/cc @grahamwhaley, @egernst, @sboeuf, @bergwolf.

@marcov
Copy link
Copy Markdown
Contributor

marcov commented Sep 7, 2018

Hi @jodh-intel, a possible approach would be to try to optimize the current image size by shaving out non essential packages, and then figure out what should be part of the image.

IMO any component that would improve security or extend support for a container engine (e.g. docker) should be considered for inclusion.

@jodh-intel
Copy link
Copy Markdown

Right - we do try to keep the default images as small as possible, but if desired users can add whichever extra packages they need using the PACKAGES= variable in the config.sh files.

@jcvenegas
Copy link
Copy Markdown
Member

@jodh-intel in the case of that way to provide a "secure" image, I wonder an easy way to configure the runtime to use it. I think is not really user friendly ask the user change that in the config file by taking any of the images we provided.

I think is not an option let the runtime open the image and check the image capabilities all the time.

@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Sep 7, 2018

@jodh-intel : Are we concluding this discussion by saying that the seccomp packages should be included by default and not made conditional? I will need to update my PR accordingly.

@jcvenegas
Copy link
Copy Markdown
Member

@jodh-intel my point is that from osbuilder perspective this is not an issue, we it can generate the types of flavors we want, but a the problem comes on how to mange this from runtime side.

@jodh-intel
Copy link
Copy Markdown

@jcvenegas - ah sorry, I'd misunderstood. Yes, we could add it to all images to make it simpler. Or, we could use the libcontainer calls to determine if the image+kernel has the support we need. If a seccomp profile is provided and the guest is not seccomp-capable, that should be an immediate error I think.

@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Sep 7, 2018

@jodh-intel : When a seccomp profile is passed and the image is not created with libseccomp support , it errors out today with the following error:

docker run -it --security-opt seccomp=sleep.json --runtime kata-runtime busybox sh
docker: Error response from daemon: OCI runtime create failed: rpc error: code = Internal desc = Could not run process: container_linux.go:348: starting container process caused "seccomp: config provided but seccomp not supported": unknown.

So, @jodh-intel should I update this PR with adding seccomp support by default and building agent by default with seccomp tag? (I was thinking of getting this feature landed this week :-) )

@jodh-intel
Copy link
Copy Markdown

@nitkon - well I'd like input from other members of the team since although this change is small, we need to understand the implications of adding non-core packages like this.

There's nothing to stop you using an osbuilder image with seccomp support for testing other parts of the seccomp story you are working on meantime though :)

/cc @sboeuf, @bergwolf, @grahamwhaley.

@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Sep 7, 2018

@jodh-intel : Sure! 👍

@nitkon nitkon force-pushed the master branch 2 times, most recently from d123c61 to 3e1125b Compare September 11, 2018 18:54
@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Sep 12, 2018

@grahamwhaley @sboeuf: polite ping.

@jodh-intel
Copy link
Copy Markdown

@nitkon - whilst we wait, one of your commits is failing checkcommits as you're using a different email address to your github-registered one fwics.

@grahamwhaley
Copy link
Copy Markdown
Contributor

l g t m - would be good if we could get the euleros fix in as well - ping @liangchenye for some confirmation...

@jodh-intel
Copy link
Copy Markdown

This is taking too long so I'm afraid if this PR doesn't work for EulerOS, it'll have to be fixed in a follow-up PR from @liangchenye.

@grahamwhaley, @jcvenegas, @sboeuf, @devimc, @amshinde - ptal so we can get this landed.

Copy link
Copy Markdown
Contributor

@grahamwhaley grahamwhaley left a comment

Choose a reason for hiding this comment

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

Looking at the history and updates then,
lgtm
@ydjainopensource - ubuntu and Euler were added (although we cannot really test Euler it seems). Are you OK with this PR now?

@grahamwhaley
Copy link
Copy Markdown
Contributor

I think we understand the Jenkins unhappyness, but Travis is not happy either:

make -C cmd/checkcommits
make[1]: Entering directory '/home/travis/gopath/src/github.com/kata-containers/tests/cmd/checkcommits'
go test .
ok  	github.com/kata-containers/tests/cmd/checkcommits	0.009s
go install -ldflags "-X main.appCommit="a23bcc204ed588142b4b74a8898710fba094fa5c" -X main.appVersion=0.0.1" .
make[1]: Leaving directory '/home/travis/gopath/src/github.com/kata-containers/tests/cmd/checkcommits'
Running checkcommits version 0.0.1 (commit a23bcc204ed588142b4b74a8898710fba094fa5c)
Detected TravisCI Environment
Found 2 commits between commit a372cbbf0aa48ba12820bcdab45f7ee52f13417c and branch master
All commit checks passed.
INFO: Checking for SPDX license headers
fatal: ambiguous argument 'origin/': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
INFO: No files found
warning: "./..." matched no packages
INFO: Installing xurls utility
INFO: Checking documentation
INFO: Checking local branch for changed documents only
fatal: ambiguous argument 'origin/': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
INFO: No documentation to check
INFO: Skipping check_files: see https://github.com/kata-containers/tests/issues/469

travis_time:end:08461f3c:start=1536741945538893828,finish=1536742004349972513,duration=58811078685
�[0Ktravis_fold:end:before_script
�[0Ktravis_time:start:17453408
�[0K$ travis_wait 30 .ci/run.sh


Still running (1 of 30): .ci/run.sh

�[31;1mThe command .ci/run.sh exited with 2.�[0m

�[32;1mLog:�[0m

INFO: running tests for all distros

INFO: Running test: Can create and run fedora image

INFO: ERROR: test failed

INFO: AGENT_INIT: 'no'

INFO: images:

total 0
INFO: rootfs:

ls: cannot access '/tmp/osbuilder-test.cC0mUbh/rootfs-osbuilder': No such file or directory
/home/travis/.travis/job_stages: line 375:  5485 Terminated              travis_jigger "${!}" "${timeout}" "${cmd[@]}"

travis_time:end:17453408:start=1536742004354785269,finish=1536742004451881417,duration=97096148
�[0K
�[31;1mThe command "travis_wait 30 .ci/run.sh" exited with 2.�[0m

@devimc
Copy link
Copy Markdown

devimc commented Sep 24, 2018

looks good but CI is not happy

@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Sep 24, 2018

@devimc @grahamwhaley @jodh-intel : Updated my PR. Travis-CI is happy now.

@devimc
Copy link
Copy Markdown

devimc commented Sep 24, 2018

the concern that has been mentioned here is that we will increase the footprint by having libseccomp enabled in the rootfs, even when no seccomp profile is applied.

I wonder if we should ship two kata-agents

@jodh-intel
Copy link
Copy Markdown

I wonder if we should ship two kata-agents

In the same image? I guess we could do that and re-exec "the other one" on demand. That would bloat the image of course - more than if we just had a single agent.

Rather than having multiple agents, I'm wondering instead if we could modularise [1] it and then dynamically load such extra features. The "fast path" would be to not load seccomp support. However, both approaches don't really help with the image bloat issue... unless the modules / 2nd agent were dynamically shared into the image.

You could argue we already have precedent for adding security-related features by default since we do this for the kernel - enabling new features and building them into the kernel. But that's almost the same issue as the agent one - maybe we should discuss again the possibility of dynamically loading kernel modules? The difference between the kernel and the agent / mini O/S though is that the kernel features tend to be significantly smaller wrt on-disk size. However, there is still the risk of death by 1000 cuts as @grahamwhaley has pointed out before.

One problem we'd have making the agent more dynamic to allow security modules to be loaded on demand... is (ironically) security: how could the agent trust the modules? If they are already part of the image, we can probably just apply the implicit trust level of the image/initrd (aka we trust it :)

Related:


[1] - or "modularize" for @egernst 😄

@grahamwhaley
Copy link
Copy Markdown
Contributor

OK, time to get back to this one.

I think a first key point is to settle the 'default image security position' for the project. As others have noted, I think it does make a lot of sense for the project to have security items enabled by default. We could then detail/document how to build an optimised setup (image, agent etc.) for users who are more concerned about space than footprint.

@kata-containers/architecture-committee - I think this is a committee call. Let me at least add it to the next meeting agenda.

@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Oct 12, 2018

Hi @grahamwhaley @jodh-intel: Was this point discussed in the committee call? Whats the final call on this? :-)

@grahamwhaley
Copy link
Copy Markdown
Contributor

Hi @nitkon It was discussed (you can see some notes here.
Yesterday I started to evaluate the cost (size and speed) of enabling the seccomp parts across agent/image/etc. - Ideally our goal is to build all parts with seccomp in them, but have it disabled by default. It is a balance of size/speed though. I will hopefully have some results next week we can then discuss further.

@caoruidong
Copy link
Copy Markdown
Member

ping @nitkon

@sboeuf
Copy link
Copy Markdown

sboeuf commented Nov 5, 2018

@grahamwhaley @nitkon what's the status on this PR?
I'm asking as I cannot recall the decision from the AC about having libseccomp in the image or not? And was it mentioned we could generate a different image?
Based on input, we need to move forward with this, as I believe some ppl might be interested in running Kata with libseccomp enabled.

@grahamwhaley
Copy link
Copy Markdown
Contributor

Oh, I meant to update this on Friday (or maybe I updated the Issue or another relevant PR)....
I am re-evaluating the metrics to measure the impact - but I need to re-run with initrd as well as .img, as initially I saw little impact on .img, but Yash saw big impact on initrd.
I did that on Friday, but the results didn't look like I expected, so I am re-evaluation. I am working on this... (I will try to progress this week)

@sboeuf
Copy link
Copy Markdown

sboeuf commented Nov 5, 2018

Thanks @grahamwhaley! We'll wait for your input then :)
Do you recall what's the AC said about having one or two different images? Just easier to track here in Github.

@grahamwhaley
Copy link
Copy Markdown
Contributor

I'm afraid I don't recall the decision about multiple img's - but, that will hang on the impact findings - if the impact is acceptable, then maybe it won't be an issue ...

@sboeuf
Copy link
Copy Markdown

sboeuf commented Nov 5, 2018

@grahamwhaley Fair enough :)

@grahamwhaley
Copy link
Copy Markdown
Contributor

@nitkon can you give this a rebase pls, and then I think we are good to merge this (as discussed over at kata-containers/runtime#689 (comment)).

Fixes: kata-containers#174

Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com
@nitkon
Copy link
Copy Markdown
Contributor Author

nitkon commented Nov 8, 2018

@egernst @grahamwhaley: Rebased my PR.

If the rootfs is built with SECCOMP=yes environment
variable then include libseccomp package inside the
rootfs image. Else do not include it.

Fixes: kata-containers#155

Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com
@sboeuf
Copy link
Copy Markdown

sboeuf commented Nov 8, 2018

/test

# as reported by `uname -m`
ARCH_EXCLUDE_LIST=()

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp" || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hi @nitkon, the || true part is not needed, if you check above your discussion with @jodh-intel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more thing: could you add the same in suse/config.sh (libseccomp2) and in template/config_template.sh (by default commented out, and you could include a brief stating your intentions)?

@grahamwhaley
Copy link
Copy Markdown
Contributor

and, oh, this CI fail I suspect is not related to this - maybe a recent CI merge has broken something....

Cloning into 'tests'...
/home/ubuntu/tests/.ci/lib.sh: line 14: GOPATH: unbound variable
Build step 'Execute shell' marked build as failure
Performing Post build task...

@grahamwhaley
Copy link
Copy Markdown
Contributor

Ooh, OK, I see what the problem is with the CI and the unbound variable.... I think it will only affect this (the osbuilder) repo right now...

In our Jenkins master script for this repo we start with:

git clone https://github.com/kata-containers/tests.git
cd tests

.ci/install_go.sh -p

export GOPATH=${WORKSPACE}/go

but, install_go.sh has:

source "${script_dir}/lib.sh"

near the top, and lib.sh now has:

lib_script="${GOPATH}/src/${tests_repo}/lib/common.bash"
source "${lib_script}"

added by me yesterday for the bare metal cleanup refactor. Oops, use of GOPATH before it has been set.....

I don't see a non-trivial correct simple fix for this, as we are trying to use GOPATH before we've even installed GO, and the osbuilder Jenkins script is using git to get a repo clone locally (outside of the GOPATH).
What we (now) do in the other repos is presume golang is installed on the Jenkins slaves, and use go get in the Jenkins master scripts to fetch the tests repo to the 'one true GOPATH place' in the first place. Maybe that is the real fix here - to fix the Jenkins master script for osbuilder.
@chavafg @jcvenegas for input on what they think is the right fix here...

@chavafg
Copy link
Copy Markdown
Contributor

chavafg commented Nov 9, 2018

@grahamwhaley what about exporting GOPATH before install_go.sh?
I think it is the easiest way and that's how we do in the jenkins_job_build.sh Basically moving https://github.com/kata-containers/ci/blob/master/jenkins/jobs/kata-containers-osbuilder-centos-7-4-PR/config.xml#L111 a couple of lines above.

@grahamwhaley
Copy link
Copy Markdown
Contributor

Sure we can @chavafg :-) My only thought was that then notionally we are setting up the GOPATH before we've theoretically installed it with install_go.sh - but, I think we can agree there is no harm here, so that should work fine. Can you do the change?

@chavafg
Copy link
Copy Markdown
Contributor

chavafg commented Nov 9, 2018

done, lets see how this goes.

/test

@egernst egernst merged commit 4af6a40 into kata-containers:master Nov 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.