Skip to content

fix: fix oom_score adjustments failing if caps set #15758

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

Merged
merged 10 commits into from
Dec 5, 2024
Merged

fix: fix oom_score adjustments failing if caps set #15758

merged 10 commits into from
Dec 5, 2024

Conversation

sreya
Copy link
Collaborator

@sreya sreya commented Dec 4, 2024

  • Fixes an issue where oom scores would fail to be adjusted in cases where the coder binary has capabilities set on it. This is because PR_SET_DUMPABLE is set to 0 when a process is executed with elevated capabilities. The fix is to flip PR_SET_DUMPABLE to 1 prior to writing to oom_score_adj.

@sreya sreya requested a review from deansheather December 4, 2024 23:30
Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

It'd be great if the test binary you compile could have caps set on it to ensure this works

@sreya
Copy link
Collaborator Author

sreya commented Dec 5, 2024

Agreed it's pretty hard to test without root

@sreya sreya requested a review from deansheather December 5, 2024 12:31
@sreya sreya requested a review from mafredri December 5, 2024 12:48
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

:shipit:

// We drop effective caps prior to setting dumpable so that we limit the
// impact of someone attempting to hijack the process (i.e. with a debugger)
// to take advantage of the capabilities of the agent process. We encourage
// users to set cap_net_admin on the agent binary for improved networking
Copy link
Member

Choose a reason for hiding this comment

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

Do we mention this in coder.com/docs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

honestly not sure

Copy link
Member

Choose a reason for hiding this comment

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

If not, we probably should (wherever we're documenting the nice/oom adjustments).

Copy link
Collaborator Author

@sreya sreya Dec 5, 2024

Choose a reason for hiding this comment

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

Yeah once this is merged and there are no bugs, I'm going to write up some documentation for resource management in Coder

@sreya sreya merged commit f8d938d into main Dec 5, 2024
30 checks passed
@sreya sreya deleted the jon/execdebug branch December 5, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants