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

Enable cgroupsv2 rw mount via security-opt unmask #9536

Merged

Conversation

jmguzik
Copy link
Contributor

@jmguzik jmguzik commented Feb 28, 2021

/fixes #8441
/Closes #8441

Introduces cgroupsv2 mounting for rootless and non privileged.

Fixes:
./bin/podman run --security-opt unmask=/sys/fs/cgroup alpine mkdir /sys/fs/cgroup/eee mkdir: can't create directory '/sys/fs/cgroup/eee': Read-only file system

Please review the design. Things to consider:

  • what to do with unmask ALL (currently also enables rw on cgroups)
  • interaction with mask (currently mounts rw but then masks)
  • SELinux can still prevent rw if enabled (checked, but did not digged in)
  • Only /sys/fs/cgroup unmasking works, subdirs - that's a different story to write

I will write docs after the design review.

@jmguzik jmguzik force-pushed the enable-cgroupsv2-sec-opts branch from cfa716f to 0a645fa Compare February 28, 2021 00:35
return ro
}

if unmask != nil && unmask[0] == "ALL" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently if ALL then "rw". I am not sure if this is desired.

Copy link
Member

Choose a reason for hiding this comment

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

I would say yes, And I think you should add

strings.ToUpper(unmask[0]) == "ALL"

Copy link
Contributor Author

@jmguzik jmguzik Mar 2, 2021

Choose a reason for hiding this comment

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

I don't think it's needed. This condition is described in BlockAccessToKernelFilesystems (line 154). I think that documentation indicates it should be ALL, not other variations.

@jmguzik jmguzik force-pushed the enable-cgroupsv2-sec-opts branch 6 times, most recently from 99bfb93 to b892f59 Compare February 28, 2021 12:14
@jmguzik jmguzik force-pushed the enable-cgroupsv2-sec-opts branch from b892f59 to d9cb135 Compare February 28, 2021 15:00
@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 1, 2021

/cc @rhatdan
Do you maybe know the reason of CI failure?
I have the feeling its unrelated to the issue.

@mheon
Copy link
Member

mheon commented Mar 1, 2021

Don't worry about that one, it's not a blocking test. We can merge with it red.

@mheon
Copy link
Member

mheon commented Mar 1, 2021

LGTM on my end

@mheon
Copy link
Member

mheon commented Mar 1, 2021

@containers/podman-maintainers PTAL

@rhatdan
Copy link
Member

rhatdan commented Mar 1, 2021

I swear I did this over the weekend, but can not find my patch, but your PR looks much nicer and has a nice tests.

Thanks @jmguzik
/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 1, 2021
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jmguzik, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 1, 2021
@rhatdan rhatdan removed the lgtm Indicates that a PR is ready to be merged. label Mar 1, 2021
@rhatdan
Copy link
Member

rhatdan commented Mar 1, 2021

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 1, 2021
@rhatdan
Copy link
Member

rhatdan commented Mar 1, 2021

Actually @jmguzik I just remembered one of the changes I had done, was to add /sys/fs/cgroup to the podman run and podman create man pages.

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 1, 2021

Yes, i will add it.

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 1, 2021

Actually @jmguzik I just remembered one of the changes I had done, was to add /sys/fs/cgroup to the podman run and podman create man pages.

Hope now its done.

docs/source/markdown/podman-create.1.md Outdated Show resolved Hide resolved
docs/source/markdown/podman-run.1.md Outdated Show resolved Hide resolved
@jmguzik jmguzik force-pushed the enable-cgroupsv2-sec-opts branch from 05b83a2 to 0a2bb71 Compare March 2, 2021 14:22
@jmguzik jmguzik requested a review from giuseppe March 2, 2021 14:24
@rhatdan
Copy link
Member

rhatdan commented Mar 2, 2021

LGTM
@containers/podman-maintainers PTAL

@rhatdan
Copy link
Member

rhatdan commented Mar 2, 2021

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2021
@mheon
Copy link
Member

mheon commented Mar 2, 2021

Restarted two flakes

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 2, 2021

Flakes are not related to the change. It seems node 1 is failing.

@mheon
Copy link
Member

mheon commented Mar 2, 2021

The F33 integration failure is consistent, not a flake. Not sure what's going on.

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 2, 2021

The F33 integration failure is consistent, not a flake. Not sure what's going on.

The only change in the code was documentation (adding ** near /sys/fs/cgroup). Previously 3x times it passed without problems. Whatever this is, it's not related to the changes.

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 2, 2021

This fail looks like an infrastructure problem.

@mheon
Copy link
Member

mheon commented Mar 2, 2021

[+0130s] fork/exec /var/tmp/go/src/github.com/containers/podman/bin/podman: no such file or directory

Hm. @cevich Any ideas?

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 3, 2021

[+0130s] fork/exec /var/tmp/go/src/github.com/containers/podman/bin/podman: no such file or directory

Hm. @cevich Any ideas?

@rhatdan @mheon Maybe I close this PR, and open identical? Will this spawn new CI resources?

@mheon
Copy link
Member

mheon commented Mar 3, 2021

@jmguzik Recommendation: make a small change to a comment somewhere in the code (spelling fix or similar) and force push with that. Should be enough to cause CI to re-fire.

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 3, 2021

@jmguzik Recommendation: make a small change to a comment somewhere in the code (spelling fix or similar) and force push with that. Should be enough to cause CI to re-fire.

@mheon yeh, I know that. Even the commit date is enough... but the question is: will it recreate the whole CI infra or just recreate jobs in-place? Anyway, I will try that...

@jmguzik jmguzik force-pushed the enable-cgroupsv2-sec-opts branch from 0a2bb71 to 81a3f8a Compare March 3, 2021 14:28
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2021
@cevich
Copy link
Member

cevich commented Mar 3, 2021

@jmguzik Recommendation: make a small change to a comment somewhere

Likely good advice. I've seen that "missing binary" error before (under different conditions), it's caused by bad/broken/failed caching from the related "Build for XYZ" tasks. My experience is re-running them didn't help, so restarting the whole CI job is the right move. Please poke me if this happens again (it's a somewhat fragile area of our CI setup).

@jmguzik
Copy link
Contributor Author

jmguzik commented Mar 3, 2021

@mheon in the end, you were right 👍

@mheon
Copy link
Member

mheon commented Mar 3, 2021

/lgtm
/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2021
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2021
@openshift-merge-robot openshift-merge-robot merged commit 87e2056 into containers:master Mar 3, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't get writable cgroups inside container without --priveleged
7 participants