Skip to content
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

tetragon: Add debug interface to track cgroups to workload/ns mappings #2540

Merged
merged 3 commits into from
Jul 1, 2024

Conversation

jrfastab
Copy link
Contributor

Debugging BPF and some kernel functions I want to understand cgroup to namespace mappings at event side. This patch maintains a stable mapping between cgroups and human readable namespaces. The end goal is to filter out noisy namespaces from execs which will be follow up series. This is minimally useful as is.

To support this just extend the use of namespace filters from kprobe and tracepoints into a more general space where we can hook selectors.

@jrfastab jrfastab requested a review from a team as a code owner June 11, 2024 20:12
@jrfastab jrfastab requested a review from kevsecurity June 11, 2024 20:12
Copy link

netlify bot commented Jun 11, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit d061804
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/66832801c1e62500086117ff
😎 Deploy Preview https://deploy-preview-2540--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jrfastab jrfastab force-pushed the pr/jrfastab/nsDebug branch 2 times, most recently from 82304ad to 24f0d6a Compare June 17, 2024 21:38
@jrfastab jrfastab added the release-note/minor This PR introduces a minor user-visible change label Jun 17, 2024
@jrfastab jrfastab force-pushed the pr/jrfastab/nsDebug branch 4 times, most recently from 03b7cd5 to e03fed9 Compare June 20, 2024 18:26
Copy link
Contributor

@willfindlay willfindlay left a comment

Choose a reason for hiding this comment

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

LGTM, just one nit.

pkg/policyfilter/namespace.go Outdated Show resolved Hide resolved
@willfindlay
Copy link
Contributor

Also needs to be run though goimports

@jrfastab jrfastab force-pushed the pr/jrfastab/nsDebug branch from e03fed9 to 490f4fb Compare June 20, 2024 21:27
Copy link
Member

@tixxdz tixxdz left a comment

Choose a reason for hiding this comment

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

So really quick review, but if you intent to raw print cgroup IDs or have them in logs somewhere better add more context if that makes sense.

bpf/process/policy_filter.h Outdated Show resolved Hide resolved
pkg/policyfilter/namespace.go Outdated Show resolved Hide resolved
cmd/tetra/policyfilter/policyfilter.go Show resolved Hide resolved
@jrfastab jrfastab force-pushed the pr/jrfastab/nsDebug branch 2 times, most recently from 2fb5314 to 5e3a860 Compare June 21, 2024 00:52
Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

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

Thanks, please find some comments below.

I think the title might be outdated because the final patch changes things to track workloads rather than namespaces.

pkg/policyfilter/namespace.go Outdated Show resolved Hide resolved
pkg/policyfilter/state.go Outdated Show resolved Hide resolved
pkg/policyfilter/namespace.go Outdated Show resolved Hide resolved
pkg/policyfilter/namespace.go Outdated Show resolved Hide resolved
@jrfastab jrfastab force-pushed the pr/jrfastab/nsDebug branch 4 times, most recently from 1811474 to f90fcd2 Compare June 25, 2024 20:17
@jrfastab jrfastab changed the title tetragon: Add debug interface to track cgroups to namespace mappings tetragon: Add debug interface to track cgroups to workload/ns mappings Jun 25, 2024
jrfastab added 3 commits July 1, 2024 15:04
We will need to use execObj() from the policyfilter pkg, but this will
cause a circular dependency. So lets just pull this out into a new pkg
that we can import.

Signed-off-by: John Fastabend <[email protected]>
Debugging BPF and some kernel functions I want to understand cgroup to
namespace/workload/kind mappings at event side. This patch maintains a
stable mapping between cgroups and human readable namespaces. The end
goal is to filter out noisy namespaces from execs which will be follow
up series. This is minimally useful as is.

To support this just extend the use of namespace filters from kprobe
and tracepoints into a more general space where we can hook selectors.

Next steps we can push namespace filters into other sensor types e.g.
loader.

Signed-off-by: John Fastabend <[email protected]>
Its sometimes useful when debugging policy statements to be able to
dump the cgroup IDs to their namespace human readable names. This
helps ensure (a) the policy maps are correctly updated and (b) if
we are debugging kernel we can map cgroups to kubernetes names.

Signed-off-by: John Fastabend <[email protected]>
@jrfastab jrfastab force-pushed the pr/jrfastab/nsDebug branch from f90fcd2 to d061804 Compare July 1, 2024 22:04
@jrfastab jrfastab merged commit e44f7df into main Jul 1, 2024
47 checks passed
@jrfastab jrfastab deleted the pr/jrfastab/nsDebug branch July 1, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants