Files
Riad Mukhtarov c56e6fb042 fix(libcontainer): fail create when a rootless container can't join its cgroup (#3803)
* fix(libcontainer): fail create when a rootless container can't join its cgroup

Since #3609 the cgroup v2 manager ignores EACCES/EROFS for every rootless
container. With an absolute linux.cgroupsPath that youki can't write to, create
succeeds but the process stays in the caller's cgroup. ps then lists nothing,
resource limits land on an empty cgroup, and delete --force exits 0 and leaves
the process running untracked.

Only tolerate the permission errors when the spec has no cgroupsPath and no
resource limits, like runc. Device rules don't count as limits. That keeps the
rootless-in-docker case from #3597 working and makes create fail otherwise.

Fixes #3794

Signed-off-by: r14dd <riad.mrv@gmail.com>

* fix(libcontainer): only count resource settings a v2 controller writes

Signed-off-by: r14dd <riad.mrv@gmail.com>

* fix(libcontainer): keep rootless device rules best effort under systemd

Podman always sets cgroupsPath, so the stricter rootless check turned off
rootless for the systemd manager too. That manager only uses it to treat
device rules as best effort, and without it creating the eBPF device filter
fails when RLIMIT_MEMLOCK can't be raised. Apply the check to the v2
manager only.

Signed-off-by: r14dd <riad.mrv@gmail.com>

* fix(libcontainer): split rootless from the cgroup permission fallback

Signed-off-by: r14dd <riad.mrv@gmail.com>

* refactor(libcgroups): add needs_to_handle to the v2 controllers

Each v2 controller reports the setting it would write, apply() uses it, and Manager::needs_to_handle answers whether any controller has work. libcontainer asks the manager instead of keeping its own has_resource_limits.

Signed-off-by: r14dd <riad.mrv@gmail.com>

* fix(libcgroups): keep an unlimited pids limit out of needs_to_handle

A negative pids limit is written as max, so it is not a limit. Manager::needs_to_handle ignores it again, as has_resource_limits did; Pids::apply is unchanged.

Signed-off-by: r14dd <riad.mrv@gmail.com>

* fix(libcgroups): treat zero values as unset and count pids -1 in needs_to_handle

Signed-off-by: r14dd <riad.mrv@gmail.com>

---------

Signed-off-by: r14dd <riad.mrv@gmail.com>
2026-11-18 10:49:40 +09:00
..
…

libcontainer

Building with musl

In order to build with musl you must first remove the libseccomp dependency as it will reference shared libraries (libseccomp) which cannot be built with musl.

Do this by using adding flags to Cargo. Use the --no-default-features flag followed by -F and whatever features you intend to build with such as v2 as defined in Cargo.toml under features section.

Next you will also need the +nightly flags when building with rustup and cargo.

# Add rustup +nightly musl to toolchain
rustup +nightly target add $(uname -m)-unknown-linux-musl

# Build rustup +nightly stdlib with musl
rustup +nightly toolchain install nightly-$(uname -m)-unknown-linux-musl

# Build musl standard library
cargo +nightly build -Zbuild-std --target $(uname -m)-unknown-linux-musl --no-default-features -F v2

cargo +nightly build --target $(uname -m)-unknown-linux-musl --no-default-features -F v2