Skip to content

Adding support of CAP_BPF and CAP_PERFMON#7301

Merged
fuweid merged 1 commit intocontainerd:mainfrom
henry118:bpfcap
Aug 18, 2022
Merged

Adding support of CAP_BPF and CAP_PERFMON#7301
fuweid merged 1 commit intocontainerd:mainfrom
henry118:bpfcap

Conversation

@henry118
Copy link
Copy Markdown
Member

Adding CAP_BPF and CAP_PERFMON

The PR adds support of CAP_BPF and CAP_PERFMON capabilities. Prior to kernel 5.8 bpf and perf_event_open requires CAP_SYS_ADMIN. This change enables finer control of the privilege setting, thus allowing us to run certain system tracing tools with minimal privileges.

Signed-off-by: Henry Wang [email protected]

@k8s-ci-robot
Copy link
Copy Markdown

Hi @henry118. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@AkihiroSuda
Copy link
Copy Markdown
Member

/ok-to-test

@estesp
Copy link
Copy Markdown
Member

estesp commented Aug 17, 2022

/retest-required

@estesp
Copy link
Copy Markdown
Member

estesp commented Aug 17, 2022

A fix for the prow/K8s-driven tests was just merged; if you can rebase on master we can get a clean CI run

@thaJeztah
Copy link
Copy Markdown
Member

Just some random comments/ramblings (perhaps they make no sense)

  • Wondering if this should also be gated by kernel version, or would that already be taken care of by the capability not being supported by older kernels? (Not sure if it's blocked before the profile is generated)
  • Are the syscalls removed from CAP_SYS_ADMIN in newer kernels, or are they gated by either? (so on kernel > 5.8 either CAP_SYS_ADMIN or CAP_BPF will give you access?)

@henry118
Copy link
Copy Markdown
Member Author

Just some random comments/ramblings (perhaps they make no sense)
Wondering if this should also be gated by kernel version, or would that already be taken care of by the capability not being supported by older kernels? (Not sure if it's blocked before the profile is generated)

These caps are defined for kernel version 5.8 here. The latest defined known kernel version is 5.9.

Are the syscalls removed from CAP_SYS_ADMIN in newer kernels, or are they gated by either? (so on kernel > 5.8 either CAP_SYS_ADMIN or CAP_BPF will give you access?)

These syscalls were not removed from CAP_SYSTEM_ADMIN, but can be separately enabled by those two new caps. In other words both CAP_SYS_ADMIN and CAP_BPF will enable bpf syscall from 5.8 onwards.

Quoted the manpage below:

CAP_SYS_ADMIN
...              
              * perform the same BPF operations as are governed by
                CAP_BPF (but the latter, weaker capability is preferred
                for accessing that functionality).
              * employ the same performance monitoring mechanisms as are
                governed by CAP_PERFMON (but the latter, weaker
                capability is preferred for accessing that
                functionality).

@AkihiroSuda
Copy link
Copy Markdown
Member

/retest-required

Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@fuweid fuweid merged commit 7c43483 into containerd:main Aug 18, 2022
@henry118 henry118 deleted the bpfcap branch August 18, 2022 16:38
@thaJeztah thaJeztah added cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch and removed cherry-pick/1.6.x labels Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants