Add support for setting capabilities on the app binary #1271
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patchset adds
linux_capabilities
underbuilds
section in.ko.yaml
. Ex:A bit of trivia on capabilities: unless running the app as root user, Docker's
--cap-add
alone is insufficient.Requested capabilities are AND-combined with capabilities granted to the app binary (intentionally simplified, see
man capabilities
for the full discourse).A running program has multiple sets of capabilities. The most important ones are
effective
(used by the kernel for permission checks) andpermitted
(a "stash" of capabilities an app can promote to effective). Likewise, file capabilities capture multiple sets of capabilities,permitted
being the most important.The config above sets
permitted
capabilities on the app binary tobpf
,perfmon
, andnet_admin
. When the app is launched, this set is AND-combined with capabilities requested via--cap-add
and the result becomes the running app'spermitted
capabilities. The app should verify if it got all required capabilities and promotepermitted
capabilities toeffective
.File capabilities have a bit that tells the kernel to automatically promote
permitted
toeffective
. The downside is that the program will fail to start with genericEPERM
error if some capabilities weren't granted. In order to access this feature, and to make transition fromDockerfile
easier, we also support the fullsetcap
syntax inlinux_capabilities
, e.g.:Fixes #1246