]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: validate input cgroup path more prudently 40840/head
authorMike Yuan <me@yhndnzj.com>
Thu, 26 Feb 2026 10:06:34 +0000 (11:06 +0100)
committerMike Yuan <me@yhndnzj.com>
Thu, 26 Feb 2026 13:23:25 +0000 (14:23 +0100)
src/core/dbus-manager.c
src/core/varlink-unit.c

index ad79c6e96abf9b5b58fd56fdb4ecb92a2d7db1ee..5e02d189072e2d7d244df4d2d7db399592f49a23 100644 (file)
@@ -652,6 +652,12 @@ static int method_get_unit_by_control_group(sd_bus_message *message, void *userd
         if (r < 0)
                 return r;
 
+        if (!path_is_absolute(cgroup))
+                return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Control group path is not absolute: %s", cgroup);
+
+        if (!path_is_normalized(cgroup))
+                return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Control group path is not normalized: %s", cgroup);
+
         u = manager_get_unit_by_cgroup(m, cgroup);
         if (!u)
                 return sd_bus_error_setf(reterr_error, BUS_ERROR_NO_SUCH_UNIT,
index c554a11f5e463e096824bc7261fee109f17496cc..3babe02732d8676b6e8ae960356d2697f6924646 100644 (file)
@@ -457,7 +457,7 @@ static int lookup_unit_by_parameters(
         }
 
         if (p->cgroup) {
-                if (!path_is_safe(p->cgroup))
+                if (!path_is_absolute(p->cgroup) || !path_is_normalized(p->cgroup))
                         return sd_varlink_error_invalid_parameter_name(link, "cgroup");
 
                 Unit *cgroup_unit = manager_get_unit_by_cgroup(manager, p->cgroup);