Files
Asifur Rahaman Meeru 969078ae4e fix(libcontainer): mount cgroup2 without the SELinux mount label (#3902)
* fix(libcontainer): mount cgroup2 without the SELinux mount label

With a mount label, cgroup2 was mounted with context=, which the
kernel refuses. The fallback then bind-mounted the cgroup path read
inside the new cgroup namespace, which is the host's root, so the
container saw the host's cgroup tree and none of its own limits.

Give cgroup2 no label in mount_label_how(), as runc and crun do, and
add a contest test that looks for the container's process in
/sys/fs/cgroup/cgroup.procs.

Fixes #3819

Signed-off-by: Asifur Rahaman Meeru <asifur.rahaman@meeru.dev>

* test(contest): run the cgroup mount label test on cgroup v2 only

The runtimetest check reads cgroup.procs at the top of the cgroup
mount, which only cgroup v2 has. On a cgroup v1 or hybrid host the
mount holds one directory per controller, so the check failed on the
missing file.

Signed-off-by: Asifur Rahaman Meeru <asifur.rahaman@meeru.dev>

---------

Signed-off-by: Asifur Rahaman Meeru <asifur.rahaman@meeru.dev>
2026-11-21 07:14:40 +09:00
..
2024-01-12 14:28:47 +05:30

Runtime test

This is the binary which runs the tests inside the container process, and checks that constraints and restrictions are upheld from inside the container. This is supposed to be rust version of runtimetest command from runtime tools.

This is primarily used from the test_inside_container function related tests in the integration tests.

Conventions

The main function will call the different tests functions, one by one to check that all required guarantees hold. This might be parallelized in future, but initially the tests are run serially.

The path of config spec will always be /spec.json , and this is fixed so that no additional env or cmd arg is required, and we don't need to depend on clap or manual parsing for that.

Make sure to consider failure cases, and try not to panic from any functions. If any error occur, or if some test fails, then it should write the error to the stderr, and return. The integration test will check stderr to be empty as an indication of all tests passing, and in case stderr is not empty, it will consider some test to be failing, and show the error as the contents of stderr. Thus make sure to include enough information in stderr message from failing tests to understand what failed in which test. There is currently no convention of explicit indication of tests passing, the passing test may write OK or something similar to stdout, but as of now, the stdout will be completely ignored by integration test.

Special Notes

This package must be compiled as a statically linked binary, as otherwise the rust compile will make it dynamically link to /lib64/ld-linux-x86-64.so , which is not available inside the container, and thus making the binary not usable inside the container process.

Note that the dynamically linked binary does not give a segmentation fault or similar error when tried to run inside the container, but instead gives no such file or directory found or executable not found error, even though the executable exists in the container. This made this tricky to debug correctly when originally developing, so if you decide on chaining the compilation or configuration of this , please make absolutely sure that the changes work and do not accidentally break something.

you can use

readelf -l path/to/binary | grep "program interpreter"  # should give empty output
file path/to/binary                                     # should specify statically linked in output

to find out if the binary is dynamically or statically linked.

Reading the Readme of integration tests can be helpful to understand how the integration tests and the runtime tests interoperate with one another.

see

https://stackoverflow.com/questions/31770604/how-to-generate-statically-linked-executables https://superuser.com/questions/248512/why-do-i-get-command-not-found-when-the-binary-file-exists https://doc.rust-lang.org/cargo/reference/config.html

for more info