teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0455-mount-setup-fix-segfault-in-mount_cgroup_controllers.patch

bd1529
From 1c8d1c3bbdf8bdfb2ee4f85b9f559f54c6e4cac4 Mon Sep 17 00:00:00 2001
bd1529
From: Wen Yang <wenyang@linux.alibaba.com>
bd1529
Date: Wed, 1 Jul 2020 04:45:33 +0800
bd1529
Subject: [PATCH] mount-setup: fix segfault in mount_cgroup_controllers when
bd1529
 using gcc9 compiler
bd1529
bd1529
According to the documentation:
bd1529
https://gcc.gnu.org/gcc-9/porting_to.html#complit
bd1529
bd1529
The 'join_controllers' that relied on the extended lifetime needs
bd1529
to be fixed, move the compound literals to the function scope it
bd1529
need to accessible in.
bd1529
bd1529
Resolves: #1868877
bd1529
---
bd1529
 src/core/mount-setup.c | 24 +++++++++++++-----------
bd1529
 1 file changed, 13 insertions(+), 11 deletions(-)
bd1529
bd1529
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
bd1529
index 16880e6157..a6594580e5 100644
bd1529
--- a/src/core/mount-setup.c
bd1529
+++ b/src/core/mount-setup.c
bd1529
@@ -237,20 +237,22 @@ int mount_cgroup_controllers(char ***join_controllers) {
bd1529
         if (!cg_is_legacy_wanted())
bd1529
                 return 0;
bd1529
 
bd1529
+        /* The defaults:
bd1529
+         * mount "cpu" + "cpuacct" together, and "net_cls" + "net_prio".
bd1529
+         *
bd1529
+         * We'd like to add "cpuset" to the mix, but "cpuset" doesn't really
bd1529
+         * work for groups with no initialized attributes.
bd1529
+         */
bd1529
+        char ***default_join_controllers = (char**[]) {
bd1529
+                STRV_MAKE("cpu", "cpuacct"),
bd1529
+                STRV_MAKE("net_cls", "net_prio"),
bd1529
+                NULL,
bd1529
+        };
bd1529
+
bd1529
         /* Mount all available cgroup controllers that are built into the kernel. */
bd1529
 
bd1529
         if (!has_argument)
bd1529
-                /* The defaults:
bd1529
-                 * mount "cpu" + "cpuacct" together, and "net_cls" + "net_prio".
bd1529
-                 *
bd1529
-                 * We'd like to add "cpuset" to the mix, but "cpuset" doesn't really
bd1529
-                 * work for groups with no initialized attributes.
bd1529
-                 */
bd1529
-                join_controllers = (char**[]) {
bd1529
-                        STRV_MAKE("cpu", "cpuacct"),
bd1529
-                        STRV_MAKE("net_cls", "net_prio"),
bd1529
-                        NULL,
bd1529
-                };
bd1529
+                join_controllers = default_join_controllers;
bd1529
 
bd1529
         r = cg_kernel_controllers(&controllers);
bd1529
         if (r < 0)