Re: [PATCH] cgroup/cpuset: reject local partitions that overlap remote CPUs
From: Ridong Chen
Date: Thu Dec 03 2026 - 21:24:59 EST
On 12/4/2026 12:45 AM, Kyuwon Cho wrote:
An invalid local partition can have a remote descendant whose CPUs come
from the top cpuset. When the local partition is made valid again,
update_parent_effective_cpumask() derives its CPUs from the parent's
effective_xcpus. That mask includes CPUs assigned to remote partitions,
unlike the parent's effective_cpus mask.
Thanks for the report. I agree the overlap is real, but I think the fix
belongs in validate_partition() rather than in
update_parent_effective_cpumask().
The root cause is a missing check in partition validation: active CPUs
newly taken by a partition must come from the effective_cpus of its
parent (top_cpuset for a remote partition), i.e. they must not be owned
by another partition. The remote side already enforces this in
remote_partition_enable() via the subpartitions_cpus check, but the local
side does not, and only has the WARN_ON_ONCE() as a safety net.
The code warns when the active CPUs are not available from the parent,
but then continues and marks the local partition valid. This lets the
local partition and its remote descendant own the same CPU:
WARNING: kernel/cgroup/cpuset.c:2057 at update_parent_effective_cpumask
RIP: update_parent_effective_cpumask (kernel/cgroup/cpuset.c:2057)
Call Trace:
cpuset_write_resmask (kernel/cgroup/cpuset.c:2622)
cgroup_file_write (kernel/cgroup/cgroup.c:4426)
kernfs_fop_write_iter (fs/kernfs/file.c:345)
vfs_write (fs/read_write.c:575)
The same condition is possible when a member cpuset containing a remote
partition is enabled as a local partition. Reject both operations with
PERR_NOCPUS instead of installing overlapping partition ownership.
Fixes: 181c8e091aae ("cgroup/cpuset: Introduce remote partition")
Signed-off-by: Kyuwon Cho <kyuwon.cho@xxxxxxxx>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. The reproducer creates a cgroup2
local partition and a remote descendant, invalidates the local
partition, lets the remote partition take its CPU, and then attempts to
recover the local partition through cpuset.cpus.exclusive. Without the
patch both partitions become owners of the CPU and the kernel warns.
With the patch recovery remains invalid with PERR_NOCPUS and no warning
occurs.
Found and tested on mainline fe6ff8d5d675 (v7.4-rc5); the patch is
against the cgroup for-next tree at 7e16ab5a117a.
kernel/cgroup/cpuset.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 3e0ed61f3a88..236bb8f47bc1 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2016,7 +2016,8 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
* Warn if it is not the case.
*/
cpumask_and(tmp->new_cpus, tmp->delmask, cpu_active_mask);
- WARN_ON_ONCE(!cpumask_subset(tmp->new_cpus, parent->effective_cpus));
+ if (!cpumask_subset(tmp->new_cpus, parent->effective_cpus))
+ return PERR_NOCPUS;
deleting = true;
} else if (cmd == partcmd_disable) {
/*
@@ -2082,7 +2083,11 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
*/
if (deleting) {
cpumask_and(tmp->new_cpus, tmp->delmask, cpu_active_mask);
- WARN_ON_ONCE(!cpumask_subset(tmp->new_cpus, parent->effective_cpus));
+ if (!cpumask_subset(tmp->new_cpus,
+ parent->effective_cpus)) {
+ part_error = PERR_NOCPUS;
+ deleting = false;
+ }
This one is not right for a valid partition. In the partcmd_update with
newmask case, addmask has already been computed at this point. Clearing
only deleting leaves adding set, and write_error then turns the partition
invalid while partition_xcpus_del() gives back only addmask. The rest of
cs->effective_xcpus stays in subpartitions_cpus and out of the parent's
effective_cpus, owned by an invalid partition.
}
} else {
/*
--
Best regards
Ridong