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

[1.2] libct/nsenter: become root after joining userns #4477

Merged
merged 2 commits into from
Oct 26, 2024

Conversation

kolyshkin
Copy link
Contributor

Backport of #4473 to release1.2. Original description follows.

PS I checked the added test case in #4476.


Containerd pre-creates userns and netns before calling runc, which
results in the current code not working when SELinux is enabled,
resulting in the following error:

runc create failed: unable to start container process: error during
container init: error mounting "mqueue" to rootfs at "/dev/mqueue":
setxattr /path/to/rootfs/dev/mqueue: operation not permitted

The solution is to become root in the user namespace right after
we join it.

Fixes #4466.

Co-authored-by: Wei Fu [email protected]
Co-authored-by: Kir Kolyshkin [email protected]
Co-authored-by: Aleksa Sarai [email protected]
Signed-off-by: lifubang [email protected]

lifubang and others added 2 commits October 25, 2024 18:13
Containerd pre-creates userns and netns before calling runc, which
results in the current code not working when SELinux is enabled,
resulting in the following error:

> runc create failed: unable to start container process: error during
container init: error mounting "mqueue" to rootfs at "/dev/mqueue":
setxattr /path/to/rootfs/dev/mqueue: operation not permitted

The solution is to become root in the user namespace right after
we join it.

Fixes opencontainers#4466.

Co-authored-by: Wei Fu <[email protected]>
Co-authored-by: Kir Kolyshkin <[email protected]>
Co-authored-by: Aleksa Sarai <[email protected]>
Signed-off-by: lifubang <[email protected]>
(cherry picked from commit c78f3f2)
Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: lifubang <[email protected]>
(cherry picked from commit 34a9285)
Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin kolyshkin added the backport/1.2-pr A backport PR to release-1.2 label Oct 26, 2024
@kolyshkin kolyshkin added this to the 1.2.1 milestone Oct 26, 2024
@kolyshkin kolyshkin changed the base branch from main to release-1.2 October 26, 2024 01:16
@kolyshkin kolyshkin changed the title 1.2 userns [1.2] libct/nsenter: become root after joining userns Oct 26, 2024
@kolyshkin kolyshkin added area/selinux SELinux area/userns User Namespaces labels Oct 26, 2024
@kolyshkin kolyshkin marked this pull request as ready for review October 26, 2024 01:18
@lifubang lifubang merged commit 0e4ee02 into opencontainers:release-1.2 Oct 26, 2024
42 checks passed
@rata rata mentioned this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/selinux SELinux area/userns User Namespaces backport/1.2-pr A backport PR to release-1.2
Projects
None yet
3 participants