Skip to content

[PROF-15441][Host Profiler] OOB SELinux to spc_t - #3275

Open
theomagellan wants to merge 1 commit into
mainfrom
theomagellan/selinux
Open

[PROF-15441][Host Profiler] OOB SELinux to spc_t#3275
theomagellan wants to merge 1 commit into
mainfrom
theomagellan/selinux

Conversation

@theomagellan

@theomagellan theomagellan commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Defaults securityContext.SELinuxOptions to type: spc_t so the host profiler can work out of the box on nodes enforcing SELinux profiles.
Adds an annotation to change the value.

Motivation

Without this, the default SELinux profile denies ptrace and the profiler only shows kernel frames.

Additional Notes

Based on https://datadoghq.atlassian.net/wiki/spaces/PROF/pages/6986172492/Accepted+Handling+of+LSMs+across+OSes.

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

Setting seLinuxOptions.type: spc_t alongside apparmor was tested on:

  • eks ubuntu / bottlerocket nodes
  • on rel-env
  • on stingchameleon and charcadet (experimental clusters)

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed (see: signing commits)

@datadog-official

datadog-official Bot commented Jul 20, 2026

Copy link
Copy Markdown

Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 46.97% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b119cb4 | Docs | Datadog PR Page | Give us feedback!

@theomagellan
theomagellan force-pushed the theomagellan/selinux branch from e3507a2 to ed9535b Compare July 21, 2026 12:02
@theomagellan
theomagellan force-pushed the theomagellan/selinux branch from ed9535b to 486bee3 Compare July 21, 2026 12:03
@theomagellan theomagellan changed the title [PROF-15441][Host Profiler] force SELinux to spc_t [PROF-15441][Host Profiler] OOB SELinux to spc_t Jul 21, 2026
@theomagellan
theomagellan marked this pull request as ready for review July 21, 2026 13:47
@theomagellan
theomagellan requested a review from a team July 21, 2026 13:47
@theomagellan
theomagellan requested a review from a team as a code owner July 21, 2026 13:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 486bee315e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +171 to +173
sc.SELinuxOptions = &corev1.SELinuxOptions{
Type: o.selinuxType,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve pod SELinux fields on the profiler

When users set pod-level spec.override.nodeAgent.securityContext.seLinuxOptions (as the OpenShift examples do with user, role, type, and level), this container-level SELinuxOptions object takes precedence for the host-profiler container, and override.PodTemplateSpec applies the pod override after feature hooks in controller_reconcile_agent.go. On SELinux/OpenShift installs that rely on those pod-level user/role/level labels, enabling host-profiler leaves this container with only the type label instead of inheriting the full pod label; preserve or merge the pod SELinux fields when setting the type.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this comment is somewhat relevant
we might want to merge ?

@theomagellan theomagellan Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pod-level securityContext has less precedence than container-level securityContext, and I think that's the correct choice and codex is getting the order wrong.

Nevertheless, I think we should always configure the Host Profiler independently of other containers in the pod given the blast radius it could have. If users want to change the SELinux profile, they can use the annotation
agent.datadoghq.com/host-profiler-selinux-type.
Additionally, I'm also not sure I understand all consequences of merging user/role/level while keeping the type override, I think this could be error-prone.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fair, I'm also not sure if this matters. The merge question is essentially what I was interested in. I was asking claude for examples:

- OpenShift with SCC: the SCC admission plugin injects user/role/level into the container's SELinuxOptions at admission time based on the SCC's seLinuxContext. So on OpenShift specifically, the container ends up with {type: spc_t, user/role/level from SCC}. Probably fine.

So let's stay consistent.
For now we can keep container-level fully replaces, annotations are available for overrides. If folks end up using overrides, or making requests to change this, we can look back into it.

Thanks

@theomagellan
theomagellan force-pushed the theomagellan/selinux branch from 486bee3 to b119cb4 Compare July 22, 2026 09:03

@r1viollet r1viollet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants