Skip to content

Commit 089f3fc

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Skip security check for hotplug induced v1 task migration
When a CPU hot removal causes a v1 cpuset to lose all its CPUs, the cpuset hotplug handler will schedule a work function to migrate tasks in that cpuset with no CPU to its ancestor to enable those tasks to continue running. If a strict security policy is in place, however, the task migration may fail when security_task_setscheduler() call in cpuset_can_attach() returns a -EACCES error. That will mean that those tasks will have no CPU to run on. The system administrators will have to explicitly intervene to either add CPUs to that cpuset or move the tasks elsewhere if they are aware of it. This problem was found by a reported test failure in the LTP's cpuset_hotplug_test.sh. Fix this problem by treating this special case as an exception to skip the setsched security check in cpuset_can_attach() when a v1 cpuset with tasks have no CPU left. With that patch applied, the cpuset_hotplug_test.sh test can be run successfully without failure. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent bbe5ab8 commit 089f3fc

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kernel/cgroup/cpuset.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,6 +3012,16 @@ static int cpuset_can_attach(struct cgroup_taskset *tset)
30123012
!cpumask_equal(cs->effective_cpus, oldcs->effective_cpus) ||
30133013
!nodes_equal(cs->effective_mems, oldcs->effective_mems);
30143014

3015+
/*
3016+
* A v1 cpuset with tasks will have no CPU left only when CPU hotplug
3017+
* brings the last online CPU offline as users are not allowed to empty
3018+
* cpuset.cpus when there are active tasks inside. When that happens,
3019+
* we should allow tasks to migrate out without security check to make
3020+
* sure they will be able to run after migration.
3021+
*/
3022+
if (!is_in_v2_mode() && cpumask_empty(oldcs->effective_cpus))
3023+
setsched_check = false;
3024+
30153025
cgroup_taskset_for_each(task, css, tset) {
30163026
ret = task_can_attach(task);
30173027
if (ret)

0 commit comments

Comments
 (0)