Skip to content

Conversation

@cyphar
Copy link
Member

@cyphar cyphar commented Oct 8, 2025

Backport of #4822 and #4812.


It makes sense to make runc exec benefit from clone2(CLONE_INTO_CGROUP), when
available. Since it requires a recent kernel and might not work, implement a fallback.

Based on:

Signed-off-by: Kir Kolyshkin [email protected]
Signed-off-by: Aleksa Sarai [email protected]

@cyphar cyphar added this to the 1.4.0-rc.2 milestone Oct 8, 2025
@cyphar cyphar added the backport/1.4-pr A backport PR to release-1.4 label Oct 8, 2025
@cyphar
Copy link
Member Author

cyphar commented Oct 8, 2025

@kolyshkin I'm guessing you still wanted this for 1.4, right?

@lifubang
Copy link
Member

lifubang commented Oct 8, 2025

@cyphar Why you didn't backport this commit: 7d6848f in #4822?

@cyphar
Copy link
Member Author

cyphar commented Oct 8, 2025

Ah, typo -- I did git cherry-pick -x commitA...commitB rather than git cherry-pick -x commitA~...commitB.

@cyphar cyphar force-pushed the 1.4-cgroup-clone-into-cgroup branch from 12534f8 to 40fb0c2 Compare October 8, 2025 06:05
@kolyshkin kolyshkin requested a review from rata October 8, 2025 07:02
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kolyshkin kolyshkin requested a review from lifubang October 8, 2025 07:10
@lifubang
Copy link
Member

lifubang commented Oct 8, 2025

@cyphar Need rebase and resolve the conflicts.

This fixes the following warning (seen on Fedora 42 and Ubuntu 24.04):

	+ sudo chown -R rootless.rootless /home/rootless
	chown: warning: '.' should be ':': ‘rootless.rootless’

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 7d6848f)
Signed-off-by: Aleksa Sarai <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit b39e0d6)
Signed-off-by: Aleksa Sarai <[email protected]>
The main idea is to maintain the code separately (and eventually kill V1
implementation).

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 5560020)
Signed-off-by: Aleksa Sarai <[email protected]>
Remove cgroupPaths field from struct setnsProcess, because:
 - we can get base cgroup paths from p.manager.GetPaths();
 - we can get sub-cgroup paths from p.process.SubCgroupPaths.

But mostly because we are going to need separate cgroup paths when
adopting cgroups.AddPid.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 5730a14)
Signed-off-by: Aleksa Sarai <[email protected]>
The main benefit here is when we are using a systemd cgroup driver,
we actually ask systemd to add a PID, rather than doing it ourselves.
This way, we can add rootless exec PID to a cgroup.

This requires newer opencontainers/cgroups and coreos/go-systemd.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 37b5acc)
Signed-off-by: Aleksa Sarai <[email protected]>
It makes sense to make runc exec benefit from clone2(CLONE_INTO_CGROUP),
if it is available. Since it requires a recent kernel and might not work,
implement a fallback to older way of joining the cgroup.

Based on:
 - https://go-review.googlesource.com/c/go/+/417695
 - coreos/go-systemd#458
 - opencontainers/cgroups#26
 - opencontainers#4822

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 5af4dd4)
Signed-off-by: Aleksa Sarai <[email protected]>
@cyphar cyphar force-pushed the 1.4-cgroup-clone-into-cgroup branch from 40fb0c2 to d792f9f Compare October 8, 2025 07:40
@cyphar
Copy link
Member Author

cyphar commented Oct 8, 2025

@lifubang Done.

@lifubang lifubang enabled auto-merge October 8, 2025 07:58
@lifubang lifubang merged commit 938693b into opencontainers:release-1.4 Oct 8, 2025
35 checks passed
@cyphar cyphar deleted the 1.4-cgroup-clone-into-cgroup branch October 8, 2025 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.4-pr A backport PR to release-1.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants