[PATCH v2] cgroup/cpuset: reject partition CPUs unavailable from parent

From: Kyuwon Cho

Date: Fri Dec 04 2026 - 01:38:17 EST


An invalid local partition can have a remote descendant whose CPUs come
from the top cpuset. When the local partition becomes valid again, its
effective exclusive mask can include a CPU that the remote partition
already removed from the parent's effective_cpus. The two partitions then
own the same CPU.

During partition validation, require each active CPU newly taken by the
partition to be available in the parent's effective_cpus. Keep allowing a
valid partition's existing effective exclusive CPUs, since those have
already been removed from the parent.

Fixes: 181c8e091aae ("cgroup/cpuset: Introduce remote partition")
Suggested-by: Ridong Chen <ridong.chen@xxxxxxxxx>
Signed-off-by: Kyuwon Cho <kyuwon.cho@xxxxxxxx>
---
Changes in v2:
- Move the overlap rejection from update_parent_effective_cpumask() into
validate_partition(), as suggested by Ridong Chen.
- Require newly acquired active CPUs to be present in the parent's
effective_cpus while allowing a valid partition's existing ownership.

v1: https://lore.kernel.org/all/179611520879.292090.13931935686523381061@xxxxxxxx/

The issue was found by an LLM-guided test generator that we are
developing as a research prototype.

The complete tools/testing/selftests/cgroup/test_cpuset_prs.sh test passes
before and after this change.

A reproducer is available on request.

kernel/cgroup/cpuset.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 3e0ed61f3a88..89505551e94e 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1449,7 +1449,7 @@ static enum prs_errcode validate_partition(struct cpuset *cs,
struct cpumask *new_excpus,
struct cpumask *del)
{
- int parent_prs;
+ int cpu, parent_prs;

if (new_prs == PRS_MEMBER)
return PERR_NONE;
@@ -1459,6 +1459,14 @@ static enum prs_errcode validate_partition(struct cpuset *cs,

if (!parent)
parent = &top_cpuset;
+ for_each_cpu_and(cpu, new_excpus, cpu_active_mask) {
+ if (cpumask_test_cpu(cpu, parent->effective_cpus))
+ continue;
+ if (is_partition_valid(cs) &&
+ cpumask_test_cpu(cpu, cs->effective_xcpus))
+ continue;
+ return PERR_NOCPUS;
+ }
parent_prs = parent->partition_root_state;
if (parent_prs > 0) {
enum prs_errcode err = prstate_housekeeping_conflict(new_prs, parent_prs,
--
2.43.0