[SRU][F][PATCH 0/1] fix all controllers mounted when using 'cgroup_no_v1='

Luke Nowakowski-Krijger luke.nowakowskikrijger at canonical.com
Thu Sep 8 21:18:20 UTC 2022


These patches come from an SRU request by Nicolas Dichtel.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1988584

[Backport]

Replaced invalfc with invalf logging function as we don't want to
backport the new changes to fs_context struct and the
corresponding logging function changes. 

The logging functions are functionally the same. 

[Impact]

When mounting a cgroup hierarchy with disabled controller in cgroup v1,
all available controllers will be attached.
For example, boot with cgroup_no_v1=cpu or cgroup_disable=cpu, and then
mount with "mount -t cgroup -ocpu cpu /sys/fs/cgroup/cpu", then all
enabled controllers will be attached except cpu.

This exists since linux v5.1 and fixed in linux v5.11 with this commit:
61e960b07b63 cgroup-v1: add disabled controller check in cgroup1_parse_param()

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=61e960b07b637

[Test Case]

root at dut-vm:~# kexec -l /boot/vmlinuz-5.4.0-122-generic --initrd=/boot/initrd.img-5.4.0-122-generic --command-line="$(cat /proc/cmdline) cgroup_no_v1=net_prio,net_cls"
root at dut-vm:~# systemctl kexec
root at dut-vm:~# mount | grep cgroup
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,cpu,cpuacct,blkio,memory,devices,freezer,perf_event,hugetlb,pids,rdma)

=> All controllers are associated to /sys/fs/cgroup/net_cls,net_prio.
Note that several reboots may be needed to reproduce the problem (it fails only when systemd tries to mount 'net_cls,net_prio' first, but the order is random).

[Regression Potential]

The patch is located in cgroup1_parse_param(), the potential regressions are low.

Chen Zhou (1):
  cgroup-v1: add disabled controller check in cgroup1_parse_param()

 kernel/cgroup/cgroup-v1.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.34.1




More information about the kernel-team mailing list