Lines Matching +full:parent +full:- +full:child
1 // SPDX-License-Identifier: GPL-2.0
32 const char *child = cgroup; in do_controller_fn() local
33 const char *parent = arg; in do_controller_fn() local
38 if (!cg_read_strstr(child, "cgroup.controllers", "cpuset")) in do_controller_fn()
41 if (cg_write(parent, "cgroup.subtree_control", "+cpuset")) in do_controller_fn()
44 if (cg_read_strstr(child, "cgroup.controllers", "cpuset")) in do_controller_fn()
47 if (cg_write(parent, "cgroup.subtree_control", "-cpuset")) in do_controller_fn()
50 if (!cg_read_strstr(child, "cgroup.controllers", "cpuset")) in do_controller_fn()
58 * The success should only depend on the parent cgroup permissions and not the
67 char *parent = NULL, *child_src = NULL, *child_dst = NULL; in test_cpuset_perms_object() local
73 parent = cg_name(root, "cpuset_test_0"); in test_cpuset_perms_object()
74 if (!parent) in test_cpuset_perms_object()
76 parent_procs = cg_name(parent, "cgroup.procs"); in test_cpuset_perms_object()
79 if (cg_create(parent)) in test_cpuset_perms_object()
82 child_src = cg_name(parent, "cpuset_test_1"); in test_cpuset_perms_object()
91 child_dst = cg_name(parent, "cpuset_test_2"); in test_cpuset_perms_object()
100 if (cg_write(parent, "cgroup.subtree_control", "+cpuset")) in test_cpuset_perms_object()
107 /* Enable permissions along src->dst tree path */ in test_cpuset_perms_object()
108 if (chown(child_src_procs, test_euid, -1) || in test_cpuset_perms_object()
109 chown(child_dst_procs, test_euid, -1)) in test_cpuset_perms_object()
112 if (allow && chown(parent_procs, test_euid, -1)) in test_cpuset_perms_object()
115 /* Fork a privileged child as a test object */ in test_cpuset_perms_object()
120 /* Carry out migration in a child process that can drop all privileges in test_cpuset_perms_object()
123 * Child process's cgroup is irrelevant but we place it into child_dst in test_cpuset_perms_object()
124 * as hacky way to pass information about migration target to the child. in test_cpuset_perms_object()
145 cg_destroy(parent); in test_cpuset_perms_object()
147 free(parent); in test_cpuset_perms_object()
163 * Migrate a process between parent and child implicitely
169 char *parent = NULL, *child = NULL; in test_cpuset_perms_subtree() local
175 parent = cg_name(root, "cpuset_test_0"); in test_cpuset_perms_subtree()
176 if (!parent) in test_cpuset_perms_subtree()
178 parent_procs = cg_name(parent, "cgroup.procs"); in test_cpuset_perms_subtree()
181 parent_subctl = cg_name(parent, "cgroup.subtree_control"); in test_cpuset_perms_subtree()
184 if (cg_create(parent)) in test_cpuset_perms_subtree()
187 child = cg_name(parent, "cpuset_test_1"); in test_cpuset_perms_subtree()
188 if (!child) in test_cpuset_perms_subtree()
190 child_procs = cg_name(child, "cgroup.procs"); in test_cpuset_perms_subtree()
193 if (cg_create(child)) in test_cpuset_perms_subtree()
197 if (chown(parent_procs, test_euid, -1) || in test_cpuset_perms_subtree()
198 chown(parent_subctl, test_euid, -1) || in test_cpuset_perms_subtree()
199 chown(child_procs, test_euid, -1)) in test_cpuset_perms_subtree()
202 /* Put a privileged child in the subtree and modify controller state in test_cpuset_perms_subtree()
205 * The unprivileged child runs in subtree too to avoid parent and in test_cpuset_perms_subtree()
206 * internal-node constraing violation. in test_cpuset_perms_subtree()
208 object_pid = cg_run_nowait(child, idle_process_fn, NULL); in test_cpuset_perms_subtree()
212 if (cg_run(child, do_controller_fn, parent) != EXIT_SUCCESS) in test_cpuset_perms_subtree()
223 cg_destroy(child); in test_cpuset_perms_subtree()
225 free(child); in test_cpuset_perms_subtree()
227 cg_destroy(parent); in test_cpuset_perms_subtree()
230 free(parent); in test_cpuset_perms_subtree()