** Description changed: [Impact] When a process is assigned to a new cgroup systemd first saves the PID of the process then enqueues the job start for the new cgroup and finally assigns the process to the cgroup after it was created. This multiple step process can generate race condition if systemd is restarted (or daemon-reload happens) after the PID has been saved but before the cgroup has been created. When systemd restarts it loses the PID assignment to the cgroup and later deletes the empty cgroup. - [Test Plan] - TODO + [Test Plan] + There is a C program attached to the big called sd_cgroup.c that creates 1000 children and assigns each of them to a cgroup. The children processes wait one minute and exit and the parent waits until all its children have finished and then finishes itself. There is also a makefile attached to compile the code. These needs libsystemd-dev installed to work. - [Where problems could occur] + While the processes are running the number of created cgroups can be + checked by running: + + systemd-cgls | grep child- | wc -l + + Normally this command should return 1000. + + To trigger the bug, the reloader.sh bash script (also attached to the + bug) should be kept running in the background. This script calls + "systemctl daemon-reload" once per second. When running the C program + while the bash script is running the systemd-cgls command should show + less than 1000 cgroups (one or two of them should be missing). + + When running the updated version of systemd, the command should always + return 1000 in all cases (with or without the reloader.sh script + running) + + Both the C program and the script should be run as root. + + [Where problems could occur] This should fix the mentioned race condition. I don't think anyone would be expecting the previous behavior because it is non deterministic. [Other Info] - This patch is available from systemd 247 so it is fixed in jammy and further versions. + This patch is available starting from systemd 247 so it is fixed in jammy and further versions.
-- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2162006 Title: Fix race condition when systemd is restarted while assigning processes to cgroups To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2162006/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
