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 2BFF63B19AF for ; Thu, 28 May 2026 09:44:09 +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=1779961450; cv=none; b=qikCq5PBYgSOiVES8tAjpqDOU+DTchVG2QKaLOXnM85t6igrFlH6/Wk1fF5tY5GoNlGBKy8k5XlhCiKBx1kip91l3mgwfVTPVpcmhCNf6BIew9zJTqmrxHv/Ka7dqh4dhZZFgsdDbAPTyT1TFK/oThxkext3oZE4njByOSlFRB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961450; c=relaxed/simple; bh=aGS8kHsEAWM2AKFrr7WF8luyyx7aqw8T0otFzSUxeiQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K7FQVRD59Dedv2cZYmV2Fs763ISULsFwk0H2l7bvSMLj0SYWqseyMhO/hJJUbwDCb43ejsx86/CYzy7JU8mTkhyXC0ihCxi6VJxzohm/ub7pINbDT6hBgDlKeta2snYuQWha0IW3n98EnmxgOlLYqxIUyuYRiFrkRikdIAzoOMQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AjCoU0ap; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AjCoU0ap" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 825D81F000E9; Thu, 28 May 2026 09:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779961449; bh=p9QkgwuRIyZMXakqefH1Ae/kAc7y1VHDznNyhMDRKq4=; h=From:To:Cc:Subject:Date:Reply-To; b=AjCoU0apaZNiaMnOQY1I2wse832D5yzllhGjDM+ikaqa7jdxBA2R7pzS1KWKBNWUP d2k53JYeG5yQWWNxAgbMkTot6J7WuRfoAWJRnoKetrMZtVkF2S9wvUPNmIPrTUlYMG 4jRqvBa5T7ikeFPFFJA5NMfLjb+N4DVggCvnSsgI= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2026-46223: cgroup: Defer css percpu_ref kill on rmdir until cgroup is depopulated Date: Thu, 28 May 2026 11:40:58 +0200 Message-ID: <2026052837-CVE-2026-46223-3e37@gregkh> X-Mailer: git-send-email 2.54.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5637; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=RntAWLbDUcd3QeZ15ypZlVRG/qHtAdG1tCFZUFQxgZI=; b=owGbwMvMwCRo6H6F97bub03G02pJDFkSvFPzTt2zerHkt0PCTl5RBmbR1b9Vfr1Zdd3hc9LPv 7b9k/vXdsSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEvrEzzOFY812tqOJ/T0aN oNXFlNm/st72FzIsOC/PEbj1ffkKl5YDjheVV3+K//1FDAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: cgroup: Defer css percpu_ref kill on rmdir until cgroup is depopulated A chain of commits going back to v7.0 reworked rmdir to satisfy the controller invariant that a subsystem's ->css_offline() must not run while tasks are still doing kernel-side work in the cgroup. [1] d245698d727a ("cgroup: Defer task cgroup unlink until after the task is done switching out") [2] a72f73c4dd9b ("cgroup: Don't expose dead tasks in cgroup") [3] 1b164b876c36 ("cgroup: Wait for dying tasks to leave on rmdir") [4] 4c56a8ac6869 ("cgroup: Fix cgroup_drain_dying() testing the wrong condition") [5] 13e786b64bd3 ("cgroup: Increment nr_dying_subsys_* from rmdir context") [1] moved task cset unlink from do_exit() to finish_task_switch() so a task's cset link drops only after the task has fully stopped scheduling. That made tasks past exit_signals() linger on cset->tasks until their final context switch, which led to a series of problems as what userspace expected to see after rmdir diverged from what the kernel needs to wait for. [2]-[5] tried to bridge that divergence: [2] filtered the exiting tasks from cgroup.procs; [3] had rmdir(2) sleep in TASK_UNINTERRUPTIBLE for them; [4] fixed the wait's condition; [5] made nr_dying_subsys_* visible synchronously. The cgroup_drain_dying() wait in [3] turned out to be a dead end. When the rmdir caller is also the reaper of a zombie that pins a pidns teardown (e.g. host PID 1 systemd reaping orphan pids that were re-parented to it during the same teardown), rmdir blocks in TASK_UNINTERRUPTIBLE waiting for those pids to free, the pids can't free because PID 1 is the reaper and it's stuck in rmdir, and the system A-A deadlocks. No internal lock ordering breaks this; the wait itself is the bug. The css killing side that drove the original reorder, however, can be made cleanly asynchronous: ->css_offline() is already async, run from css_killed_work_fn() driven by percpu_ref_kill_and_confirm(). The fix is to make that chain start only after all tasks have left the cgroup. rmdir's user-visible side then returns as soon as cgroup.procs and friends are empty, while ->css_offline() still runs only after the cgroup is fully drained. Verified by the original reproducer (pidns teardown + zombie reaper, runs under vng) which hangs vanilla and succeeds here, and by per-commit deterministic repros for [2], [3], [4], [5] with a boot parameter that widens the post-exit_signals() window so each state is reliably reachable. Some stress tests on top of that. cgroup_apply_control_disable() has the same shape of pre-existing race: when a controller is disabled via subtree_control, kill_css() ran synchronously while tasks past exit_signals() could still be linked to the cgroup's csets, and ->css_offline() could fire before they drained. This patch preserves the existing synchronous behavior at that call site (kill_css_sync() + kill_css_finish() back-to-back) and a follow-up patch will defer kill_css_finish() there using a per-css trigger. This seems like the right approach and I don't see problems with it. The changes are somewhat invasive but not excessively so, so backporting to -stable should be okay. If something does turn out to be wrong, the fallback is to revert the entire chain ([1]-[5]) and rework in the development branch instead. v2: Pin cgrp across the deferred destroy work with explicit cgroup_get()/cgroup_put() around queue_work() and the work_fn. v1 wasn't actually broken (ordered cgroup_offline_wq + queue_work order in cgroup_task_dead() saved it) but the explicit ref removes the dependency on those non-obvious invariants. Also note the pre-existing cgroup_apply_control_disable() race in the description; a follow-up will defer kill_css_finish() there. The Linux kernel CVE team has assigned CVE-2026-46223 to this issue. Affected and fixed versions =========================== Issue introduced in 7.0 with commit 1b164b876c36c3eb5561dd9b37702b04401b0166 and fixed in 7.0.9 with commit 33fa2e6b1507a0a377a151a8826438bedad1d0b0 Issue introduced in 7.0 with commit 1b164b876c36c3eb5561dd9b37702b04401b0166 and fixed in 7.1-rc3 with commit 93618edf753838a727dbff63c7c291dee22d656b Issue introduced in 6.19.12 with commit 78c72bce4a87819126211c0d24e18350010604fb Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2026-46223 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: include/linux/cgroup-defs.h kernel/cgroup/cgroup.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/33fa2e6b1507a0a377a151a8826438bedad1d0b0 https://git.kernel.org/stable/c/93618edf753838a727dbff63c7c291dee22d656b