Repository navigation
Conversation
Add a cgroupfs contest group covering default and explicit device denial, character-device access, and block-device reads. The deny cases write to and read /dev/kmsg: one has only a deny-all rule, the other grants and then revokes access. The allow cases write to and open /dev/kmsg, and read one byte with dd from a block device that was readable on the host, skipping empty and removable devices. Skip only cases whose host device prerequisites are unavailable. Fixes youki-dev#3605 Signed-off-by: Asifur Rahaman Meeru <asifur.rahaman@meeru.dev>
603ddc4 to
b4e2277
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the added creation-time cgroup v2 device-access tests.
No open issues 🎉
What changed in this PR
Adds creation-time device-access coverage to contest’s cgroup v2 integration tests using cgroupfs. Update-time behavior remains scoped to #3930.
Changes:
- Adds four tests covering default denial, explicit denial, character-device access, and block-device reads.
- Uses real device operations, with host prerequisite checks that skip unavailable devices.
- Registers the new
cgroup_v2_devicestest group.
| File | Description |
|---|---|
tests/contest/contest/src/tests/cgroups/mod.rs |
Exposes the new devices test module. |
tests/contest/contest/src/tests/cgroups/devices.rs |
Implements and registers four device-access tests with shared setup and host prerequisite checks. |
Review effort: Balanced
|
Is there a reason for performing device access validation in |
No strong reason. I followed runc's dev.bats, which mostly probes with shell commands, rather than reusing I'll rework the group to run |
If both can be done without significant changes, please include them in this PR. Ideally, the tests should cover all three device access permissions: r (read), w (write), and m (mknod). |
I'll add the write check and move the helpers. For |
|
Thanks for investigating. That approach sounds good to me. |
Replace the shell probes in the cgroup_v2_devices group with runtimetest's device_cgroup check, as the systemd device tests do, and move the spec helpers both groups use into utils. device_cgroup now checks writes as well as reads, so the systemd group gets the write check too. mknod is not covered: both runtimes append allow b *:* m and allow c *:* m, and how a deny of it should behave is open in youki-dev#3911. Signed-off-by: Asifur Rahaman Meeru <asifur.rahaman@meeru.dev>
Description
Add a
cgroup_v2_devicescontest group for cgroupfs. Like the systemd device tests, it runs runtimetest'sdevice_cgroupcheck inside the container, which opens block nodes the runtime created and compares EPERM against the spec's rules, so it needs no host devices. The four cases are default deny, deny-all with an allow and a redundant deny, a deny on top of allow-all, and an allow followed by a write deny.device_cgroupnow checks writes as well as reads, so the systemd device group gets the write check too. The spec helpers both groups use move fromsystemd/devices.rstoutils/cgroups.rs.mknod is not covered: both runtimes append
allow b *:* mandallow c *:* m, and how a deny of it should behave is open in #3911.Type of Change
Testing
On aarch64 with kernel 7.3, cgroup v2 and systemd 262, as root, release youki and runc 1.5.3 each pass all four
cgroup_v2_devicestests and all fivecgroup_systemd_devicestests with no skips. This host has no 8:x disk, so the allowed opens return ENXIO.Mutation checks on youki's device rule code, against
cgroup_v2_devices:arule always switch to allow-all failsdevice_default_denyanddevice_allow_with_redundant_deny.waccess bit asrfails the other three tests.Full
just lintpasses.cargo test --locked -p contest -p runtimetest --all-targetspasses.Related Issues
Fixes #3605
Additional Context
Update-time device preservation and its regression tests are handled in #3930. This PR adds only the creation-time coverage requested in #3605.