Skip to content

Conversation

@0xDVC
Copy link

@0xDVC 0xDVC commented Oct 30, 2025

Remove incomplete CLI validation that only checked --pod flag and missed --pod-id-file (used by quadlet). Move validation to libpod/container_validate.go to catch all cases where --userns is set with --pod.

The new validation checks if container's ID mappings differ from the pod's
infra container and returns a clearer error message:
'cannot set user namespace mappings that differ from pod'

Fixes: #26848

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

Improved validation and error message when setting user namespace for containers in pods. Now properly catches all cases including quadlet configurations.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 30, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 0xDVC
Once this PR has been reviewed and has the lgtm label, please assign nalind for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@0xDVC 0xDVC force-pushed the fix-26848-userns-pod-validation branch from 6059c1f to 5a7b73a Compare October 30, 2025 23:50
@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

2 similar comments
@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@0xDVC 0xDVC force-pushed the fix-26848-userns-pod-validation branch 9 times, most recently from 88b5145 to d5700bc Compare October 31, 2025 12:29
// Linux requires containers sharing network or IPC namespaces (like in a pod) to use the same
// user namespace. Trying to use different ones will fail at the kernel level.
// Most of this is already checked in pkg/specgen/generate/namespaces.go before pod containers drop their ID mappings.
func (c *Container) validateUserNSInPod() error {
Copy link
Member

Choose a reason for hiding this comment

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

this is not my area of expertise, but what am I missing here? All conditions including the default return nil?

Copy link
Author

Choose a reason for hiding this comment

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

good catch, totally missed removing that. Earlier in development, I was focusing on libpod/container_validate.go as suggested when I started work. I realized that by the time that call runs, the ID mappings had already been dropped (in namespaces.go lines 265-269), so I would have missed catching the error. namespaces.go is where the actual validation is happening.

removing it now.

@0xDVC 0xDVC force-pushed the fix-26848-userns-pod-validation branch 3 times, most recently from ff9fe1c to 181f6ca Compare October 31, 2025 14:19
Remove incomplete CLI validation that only checked --pod flag and missed
--pod-id-file (used by quadlet). Move validation to libpod/container_validate.go
to catch all cases where --userns is set with --pod.

The new validation checks if container's ID mappings differ from the pod's
infra container and returns a clearer error message:
'cannot set user namespace mappings that differ from pod'

This addresses the issue request for a better error message that explains
the kernel limitation more clearly.

Fixes: containers#26848
Signed-off-by: 0xdvc <[email protected]>
@0xDVC 0xDVC force-pushed the fix-26848-userns-pod-validation branch from 181f6ca to 502a145 Compare October 31, 2025 15:04
@TomSweeneyRedHat
Copy link
Member

Tests are unhappy, I'm not sure what's what with them. I'm going to try a rerun of the failed ones.

@0xDVC
Copy link
Author

0xDVC commented Oct 31, 2025

Tests are unhappy, I'm not sure what's what with them. I'm going to try a rerun of the failed ones.

Literally😂. For most, quite a learning experience. The rest? Got me at a choke hold.

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.

Per Container User Namespaces in Pod Quadlets?

3 participants