Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF48821773D for ; Fri, 22 May 2026 12:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779454464; cv=none; b=tuelIT6zkzeFEWrR6WTocU7nBWdfORDLQYp2twxNeo7Vv7UBtxz9NpPXM+X296pmaAOk+XqGH8O8k+mQXzbWlm3x5BNYDXlP7h3tpnstujRKKlUUu7Tml4/2uFrhyjV4BeRC7x6qD0ncEKwsjbrmRZJcROV5UytFVwE9EQBEw3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779454464; c=relaxed/simple; bh=9bRdBTqMK02zDHhh7cmOsaPch2aigXaefoAJ4J9uJCU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y8zcGC8c3z/IMcBsIbXeXZRRoLw0voVz/BXVsX7O+lniAFnq3aWNcgeY+C0meAYFnxbRPzETptbSQuw+EJqoU0K2+wGXajHVdoh6uqQFJBEL6XqZ4V3ZGNAR4f+flTvgymKGpTOfSEceFKEsJBwdE3hbSloH3j/Q2qisvbBow2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PTJ5LO7X; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PTJ5LO7X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6F4E1F000E9; Fri, 22 May 2026 12:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779454462; bh=bVRLfClscL+U4XprW3LSlZGBSIAMXP/qTANegFo3KWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PTJ5LO7XJP7JApj7gPxwLWsAXgzMKpgwbX3rA0Uk15us3UY3HoI3A7FtYT7VgolGE 2lTfG9S002ZfXDCOZViJpdpeBZ7wngLx0m+qLaWO2/jrn0BP48kuaemPnlE72zpaBw AuKV4BPUDNWEONhA5TaqJBtm0DgNya1hoMVqQ3hiEypVafAcMSfg8v+Dhm+3KoMZ7i EqG2qgccCEjaUNQkYH3C33Llyf1YrZDsQC4aXNrdXZOaRzd34+xFNayMznVJ5HmaOw slwu2D9Cli0HUXaGU8cVrjbO6Rd0gsVpGwxAwOw4Wu6fmQr84Mp/v4BSsYv47sc56B eU9bWGmkuV2IA== From: Sasha Levin To: stable@vger.kernel.org Cc: Guopeng Zhang , Tejun Heo , Chen Ridong , Waiman Long , Sasha Levin Subject: [PATCH 6.18.y] cgroup/cpuset: Reset DL migration state on can_attach() failure Date: Fri, 22 May 2026 08:54:20 -0400 Message-ID: <20260522125420.3841043-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026051950-charbroil-unbutton-3311@gregkh> References: <2026051950-charbroil-unbutton-3311@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Guopeng Zhang [ Upstream commit 4a39eda5fdd867fc39f3c039714dd432cee00268 ] cpuset_can_attach() accumulates temporary SCHED_DEADLINE migration state in the destination cpuset while walking the taskset. If a later task_can_attach() or security_task_setscheduler() check fails, cgroup_migrate_execute() treats cpuset as the failing subsystem and does not call cpuset_cancel_attach() for it. The partially accumulated state is then left behind and can be consumed by a later attach, corrupting cpuset DL task accounting and pending DL bandwidth accounting. Reset the pending DL migration state from the common error exit when ret is non-zero. Successful can_attach() keeps the state for cpuset_attach() or cpuset_cancel_attach(). Fixes: 2ef269ef1ac0 ("cgroup/cpuset: Free DL BW in case can_attach() fails") Cc: stable@vger.kernel.org # v6.10+ Signed-off-by: Guopeng Zhang Signed-off-by: Tejun Heo Reviewed-by: Chen Ridong Reviewed-by: Waiman Long [ omitted upstream context line `cs->dl_bw_cpu = cpu;` ] Signed-off-by: Sasha Levin --- kernel/cgroup/cpuset.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 08b0c264bd268..5057cf44342b5 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3163,16 +3163,13 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) int cpu = cpumask_any_and(cpu_active_mask, cs->effective_cpus); if (unlikely(cpu >= nr_cpu_ids)) { - reset_migrate_dl_data(cs); ret = -EINVAL; goto out_unlock; } ret = dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); - if (ret) { - reset_migrate_dl_data(cs); + if (ret) goto out_unlock; - } } out_success: @@ -3181,7 +3178,10 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) * changes which zero cpus/mems_allowed. */ cs->attach_in_progress++; + out_unlock: + if (ret) + reset_migrate_dl_data(cs); mutex_unlock(&cpuset_mutex); return ret; } -- 2.53.0