core: refuse cgroupv1 unless SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE

Also, add a 30s sleep even if cgroup v1 is forced.

Closes #30852
This commit is contained in:
Mike Yuan
2024-02-27 23:10:49 +08:00
parent f4f3efa4d7
commit f2512de82d
2 changed files with 14 additions and 1 deletions
+11 -1
View File
@@ -3017,11 +3017,21 @@ int main(int argc, char *argv[]) {
}
if (!skip_setup) {
/* Before we actually start deleting cgroup v1 code, make it harder to boot
* in cgroupv1 mode first. See also #30852. */
r = mount_cgroup_legacy_controllers(loaded_policy);
if (r < 0) {
error_message = "Failed to mount cgroup v1 hierarchy";
if (r == -ERFKILL)
error_message = "Refusing to run under cgroup v1, SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1 not specified on kernel command line";
else
error_message = "Failed to mount cgroup v1 hierarchy";
goto finish;
}
if (r > 0) {
log_full(LOG_CRIT, "Legacy cgroup v1 support selected. This is no longer supported. Will proceed anyway after 30s.");
(void) usleep_safe(30 * USEC_PER_SEC);
}
}
/* The efivarfs is now mounted, let's lock down the system token. */
+3
View File
@@ -518,6 +518,9 @@ int mount_cgroup_legacy_controllers(bool loaded_policy) {
if (!cg_is_legacy_wanted())
return 0;
if (!cg_is_legacy_force_enabled())
return -ERFKILL;
FOREACH_ARRAY(mp, cgroupv1_mount_table, ELEMENTSOF(cgroupv1_mount_table)) {
r = mount_one(mp, loaded_policy);
if (r < 0)