-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Don't set ambient caps without inheritable ones #4367
Conversation
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, thanks!
However, IMHO, it would be great to document why we removed inheritable capabilities in the first place. It is clear that if we remove inh, we should remove ambient too.
All I remember it was a security fix, originally reported by cap maintainers (Andrew Morgan). Something along the lines that inheritable capabilities are usually being set from the file system attributes, and are not expected to be set this way ( |
ffcf438
to
82c2c68
Compare
Another problem, maybe there is a situation we should consider: If this is true, I think this PR is wrong. |
With a single @lifubang try to look at this PR in the following way:
So what this PR does is removes ambient caps which are not being set anyway (they are ignored). In other words, it changes nothing. |
So, what you mean is that the ‘inheritable caps’ should always be empty in ‘config.json’? |
Probably not always, but by default they should be empty. Whence, ambient caps should also be empty by default, since it's not possible to set ambient without inheritable. Hope that clears things up. |
82c2c68
to
6391b24
Compare
6391b24
to
c5c3c35
Compare
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
Waiting #4412 merged to unblock CI.
Commit 98fe566 removed setting inheritable capabilities from runc exec --cap, but neglected to also remove ambient capabilities. An ambient capability could only be set if the same inheritable capability is set, so as a result of the above change ambient capabilities were not set (but due to a bug in gocapability package, those errors are never reported). Once we start using a library with the fix [1], that bug will become apparent. Alas, we do not have any tests for runc exec --cap, so add one. Yet, if some inheritable bits are already set from spec, let's set ambient to avoid a possible regression. Add a test case for that, too. [1]: kolyshkin/capability#3 Fixes: 98fe566 ("runc: do not set inheritable capabilities") Co-authored-by: lifubang <lifubang@acmcoder.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Commit 98fe566 removed inheritable capabilities from the example spec (used by runc spec) and from the libcontainer/integration test config, but neglected to also remove ambient capabilities. An ambient capability could only be set if the same inheritable capability is set, so as a result of the above change ambient capabilities were not set (but due to a bug in gocapability package, those errors are never reported). Once we start using a library with the fix [1], that bug will become apparent (both bats-based and libct/int tests will fail). [1]: kolyshkin/capability#3 Fixes: 98fe566 ("runc: do not set inheritable capabilities") Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The example is too long since it lists too many capabilities. Simplify it, leaving only two capabilities. Also, remove ambient capabilities from the set. Inheritable capabilities were removed earlier by commit 98fe566, but ambient capabilities can't be raised without inheritable ones. Fixes: 98fe566 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
c5c3c35
to
7a44910
Compare
Commit 98fe566 removed setting inheritable capabilities from
runc exec --cap
;runc spec
);but neglected to also remove ambient capabilities.
An ambient capability could only be set if the same inheritable
capability is set, so as a result of the above change ambient
capabilities were not set (but due to a bug in gocapability package,
those errors are never reported).
Once we start using a package with the fix, that bug will become
apparent (both bats-based and inct/int tests will fail).
This PR removes setting ambient capabilities where inheritable ones
are not set. This has no effect in the current codebase (since those
ambient capabilities were not set anyway, and the errors were ignored),
but will prevent errors once we switch to the fixed capability package.
As we do not have any tests for
runc exec --cap
, add one.