The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] cgroup/cpuset: reject local partitions that overlap remote CPUs
@ 2026-12-03 16:45 Kyuwon Cho
  2026-12-04  2:24 ` Ridong Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-12-03 16:45 UTC (permalink / raw)
  To: Waiman Long, Ridong Chen, Tejun Heo, Johannes Weiner,
	Michal Koutný
  Cc: cgroups, linux-kernel

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.

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@skku.edu>
---
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;
+			}
 		}
 	} else {
 		/*
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  2:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 16:45 [PATCH] cgroup/cpuset: reject local partitions that overlap remote CPUs Kyuwon Cho
2026-12-04  2:24 ` Ridong Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox