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:1.1: resolve uid to username for exec events from /proc fs #2603

Merged
merged 6 commits into from
Jun 26, 2024

Conversation

tixxdz
Copy link
Member

@tixxdz tixxdz commented Jun 24, 2024

tetragon: resolve uid to username for exec events from /proc fs

tixxdz added 5 commits June 24, 2024 16:34
[Upstream main d2b5c6a ]

[Includes username fix Upstream main 96e5028 ]

Cache UIDs/Usernames so we reduce:
- I/O on /etc/passwd for each execution especially for root user and
  other system user IDs as by default lot of software runs under those.
- Some users may watch /etc/passwd access, so caching those entries
  will reduce Tetragon generated events and improve performance overall.

We only cache UIDs from 0..999 as these are considered standard
system users, that are set by most distros packages. Distros maintainers
usually do great job to not clash such users. For anything above > 999
we do not cache it, we can that if users want such support later.

Reference:
https://github.com/systemd/systemd/blob/main/docs/UIDS-GIDS.md#summary

Signed-off-by: Djalal Harouni <[email protected]>
[ Upstream main dac9959 ]

Signed-off-by: Djalal Harouni <[email protected]>
Right now we resolve uid->username only for processes that
start after tetragon. To also handle the ones that start before,
we need to resolve the username during /proc fs scanning.

This patch adds userinfo module part of sensors/exec and call it
for both bpf exec sensors and proc_reader procfs scanning.

We keep same semantics if a process is not in mount and user host
namespaces we do not resolve its username.

Signed-off-by: Djalal Harouni <[email protected]>
@tixxdz tixxdz requested review from a team, mtardy and willfindlay as code owners June 24, 2024 15:37
@tixxdz tixxdz changed the base branch from main to v1.1 June 24, 2024 15:37
@tixxdz tixxdz added the release-note/minor This PR introduces a minor user-visible change label Jun 24, 2024
Copy link

netlify bot commented Jun 24, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 745f46b
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/667992abe3f41b000840123e
😎 Deploy Preview https://deploy-preview-2603--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.

@tixxdz tixxdz changed the title tetragon:1.1: resolve uid to username for exec events from /proc fs #2588 tetragon:1.1: resolve uid to username for exec events from /proc fs Jun 24, 2024
Add two metrics:

- process_metadata_username_ignored_not_in_host_namespaces:
  This is to note that we did not perform uid->username resolution
  and it was ignored due the target process not being in mount or
  user host namespaces.

- process_metadata_username_failed: that is to note that we did
  try to resolve target process uid->username but it failed for some
  reasons.

Signed-off-by: Djalal Harouni <[email protected]>
@tixxdz tixxdz force-pushed the pr/tixxdz/backports-1.1-username-from-procfs branch from 745f46b to ff514d1 Compare June 24, 2024 20:52
@tixxdz tixxdz requested a review from kkourt June 24, 2024 20:53
@kkourt kkourt merged commit 520dbc8 into v1.1 Jun 26, 2024
36 checks passed
@kkourt kkourt deleted the pr/tixxdz/backports-1.1-username-from-procfs branch June 26, 2024 13:23
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.

2 participants