From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.194 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796351092; b=KXcD+L7ZPwDvtrOm5kQzKlPJ2UVMenG1fYb3YNP4p9iTzRFQH8u8ny7vtCAwAbYMOC0L T4++6hat15xj1Mp+cgh0aew5jqpD4q09qCnhczMPW295qE8uCnS6DKneASQV1tDueiE2c o4lvHnhbEz7fPgiGqcbF5TwOS0b+Ovgnrc9rGBa1Koq00Zf7HAEhDsgRdXvCkchb2TUCb 1dbcGTl3e5gQEzVxrbbu+nrDlm89McmOhf0eTilD6qO92sh/70zpIGLeDgiEMJqaKLoth IPP0ydyo0h8ARx6fGYwWjUPBlIqs94NWEw2DwbyFkidHqCk7YuN2JbsyTyU8S8eq7fQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796351092; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=zB0gTHPgVvjK3MThZnthbqDZyceyGgeix0jryoUmpkQ=; b=Aa9NoJwQ5qd3ezzs8cFbnFMjmLz2QsB9WBHbbHqdrH9TQAHmNrGe36VBOX470cpegBSx tTtYDjLpzEXu4taz+AoW1DZcFeGGiAHtHPQg20hw1mBnW99ayWhTvgbyDzqyDNih6rV6O 7U1ZMzqMm3M0Od2timSYV6b/XyvGb7rN0Y0LcpL/MIB3mj+OvKS/ixwq5ZIWfwxXjtb0S TXOLxUAvvP/adwOXmt63ErSb6rADIE0jljpmSPAIetkHekDni7CCmr2ax5pP7dP8pnb9H mSduFrU5jKK+i78PyU3ml9HOL+l8ReaIRHj5VT8T444hoe+dWOMn2O+ZCkUcwprp8Lg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="pIOzY/Sr"; arc=none smtp.remote-ip=95.215.58.194 Received: from mta1.migadu.com (out-194.mta1.migadu.com [95.215.58.194]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A26D9606A322 for ; Fri, 4 Dec 2026 02:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A26D9606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=pIOzY/Sr X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=Pno5GvE0CgR7F/1ECALxHTMCJ6+2o9xcqEGifsW5/hk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796351089; v=1; x=1796955889; b=pIOzY/Sr61MyGreSMbIXQk7MYur5dxHqkKyGmfsO6pIBwkAbF8/GCwIzc3sUVD8u3GJRGP4d swvLvo72DZGeYMp/9lRzKalXn4z4HHZ3K759wYvhao1WoJR7MKOiHu+7QeoSDdhcdu2a8r4+lba iSfRJSkBc1yB5dJpC4qcap18= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 845f900b1ee6a8ea; Fri, 04 Dec 2026 02:24:49 +0000 X-Mizu-Trace-ID: 845f900b1ee6a8ea X-Migadu-Flow: FLOW_OUT Message-ID: <311db065-5f72-4f8a-9db0-341aea19fa28@linux.dev> Date: Fri, 4 Dec 2026 10:24:45 +0800 X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] cgroup/cpuset: reject local partitions that overlap remote CPUs To: Kyuwon Cho , Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <179611520879.292090.13931935686523381061@skku.edu> From: Ridong Chen In-Reply-To: <179611520879.292090.13931935686523381061@skku.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > --- > 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