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

Mask /sys/devices/virtual/powercap #20501

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

mheon
Copy link
Member

@mheon mheon commented Oct 26, 2023

I don't really like this solution because it can't be undone by --security-opt unmask=all but I don't see another way to make this retroactive. We can potentially change things up to do this the right way with 5.0 (actually have it in the list of masked paths, as opposed to adding at spec finalization as now).

NONE

@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 26, 2023
@mheon mheon force-pushed the powercap branch 2 times, most recently from 0d50cee to 55bfd71 Compare October 26, 2023 21:07
I don't really like this solution because it can't be undone by
`--security-opt unmask=all` but I don't see another way to make
this retroactive. We can potentially change things up to do this
the right way with 5.0 (actually have it in the list of masked
paths, as opposed to adding at spec finalization as now).

Signed-off-by: Matthew Heon <[email protected]>
@mheon
Copy link
Member Author

mheon commented Oct 26, 2023

Had to disable the test, as our CI VMs don't have the file in question anyways.

@mheon
Copy link
Member Author

mheon commented Oct 26, 2023

This should be ready.
@lsm5 this will need to be in 4.7.2
@Luap99 @baude @vrothberg @ashley-cui PTAL

@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

Copy link
Member

@ashley-cui ashley-cui left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 27, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon, vrothberg

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 openshift-ci bot merged commit 7d5af58 into containers:main Oct 27, 2023
82 of 99 checks passed
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

I do not like the fact that it does not work correctly for new containers created with unmask=/sys/devices/virtual/powercap. Should we add a new option to the container config to indicate the container was created after this patch and then do not apply this logic because for new containers we should definitely add it to BlockAccessToKernelFilesystems() in the spec generation.

@@ -805,3 +805,9 @@ func (c *Container) makePlatformMtabLink(etcInTheContainerFd, rootUID, rootGID i
func (c *Container) getPlatformRunPath() (string, error) {
return "/run", nil
}

func (c *Container) addMaskedPaths(g *generate.Generator) {
if !c.config.Privileged {
Copy link
Member

Choose a reason for hiding this comment

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

should we also add && len(g.Config.Linux.MaskedPaths) != 0 as check here? if umask=all is set it would mean we do not add the path which seems more desirable.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @Luap99, it'd be better to have a way to not mask it.

Otherwise we have no way to have an unmasked /sys in the container and I think that breaks mounting /sys in a nested container

@lsm5
Copy link
Member

lsm5 commented Oct 27, 2023

This should be ready. @lsm5 this will need to be in 4.7.2

/cherry-pick v4.7

@openshift-cherrypick-robot
Copy link
Collaborator

@lsm5: new pull request created: #20509

In response to this:

This should be ready. @lsm5 this will need to be in 4.7.2

/cherry-pick v4.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@mheon
Copy link
Member Author

mheon commented Oct 27, 2023

@giuseppe @Luap99 I share your concerns, but introducing some sort of versioning to the container config to indicate whether it was created before or after the change is sufficiently drastic I'd like to push it out to 5. We will probably want a way to migrate existing containers to the new, changed config (podman system migrate, probably, that was its original intent) as well.

@TomSweeneyRedHat
Copy link
Member

Just noting a hold was placed on #20509 until this discussion is resolved. @mheon, if this is settled, can you release #20509, please?

@Luap99
Copy link
Member

Luap99 commented Oct 27, 2023

This has the potential to cause regressions, if there is no way to undo that then we have problems and that cannot wait for a 5.0.

I personally see no problem to add a simple int field to the container config and set this to 1 for all new containers, the old ones will have 0 as default. Then you can check if it is a new one and do not apply this logic because new ones should be set correctly in the specgen were we handle masked paths right now.

@giuseppe
Copy link
Member

I think the suggestion from @Luap99 to add && len(g.Config.Linux.MaskedPaths) != 0 should be enough for now without overcomplicating the configuration.

At some point, we can drop this check completely and just use /sys/devices/virtual/powercap from the default configuration for new containers

@TomSweeneyRedHat
Copy link
Member

Partially addresses https://issues.redhat.com/browse/RHEL-12098 and https://issues.redhat.com/browse/RHEL-12097. A vendor of Buildah with the fix is needed to complete the fix.

@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 Feb 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
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. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants