Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DADC62EC0B3 for ; Tue, 30 Dec 2025 12:22:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767097362; cv=none; b=is4Dz0/q3lSv9S9a1fl0zxpTjK58bHHB5JGj2OOo9hxevkH94g5Lay8HxaehHPv3WU0WK58c/FsfzH+nfM5acHR3agYP2Skz0cfMOuPxDpFDoT7CGDBeJzAD0syeaaXpRYRurh5eiEHN/YB2/fuEMunDzTRUWdhuLxJLDyWuexo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767097362; c=relaxed/simple; bh=MWvy35no49lI6MhDX1bUGwe/GGao6Otugn+9DWC9WrU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DQmDLWnfXFjekYG8ZkQscZONNiDTdrW5z74u5KkvvtvoDnGmj+2HXPFMDu0w7r/x/lgcXTEKXTEsdCqnR4bV8SGd27xLC8mJdL4BnbaiiDthTr6+IBaBMqz/LBzCtUs93WwEHP66LFA3/30a4MtXhud0UeMrLWOcmpFTMfwYarQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QFWkvsQh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QFWkvsQh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60353C4CEFB; Tue, 30 Dec 2025 12:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767097362; bh=MWvy35no49lI6MhDX1bUGwe/GGao6Otugn+9DWC9WrU=; h=From:To:Cc:Subject:Date:Reply-To:From; b=QFWkvsQhySLb6lvEuRNlYKHpBcyM93f9QuarOuqUnqDZVALUvvGRqIvLyI8dTGChb +3CUjmhtVD1FA1VAXNd7Y2zODhMYvGmBD6V8EH4P2bw14Sorfwd1VgIvNwndtNbMr2 Kzy9B0A73ccQa8q/C31VYmgdOyosoGgxvpnzkSp4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-54271: blk-cgroup: Fix NULL deref caused by blkg_policy_data being installed before init Date: Tue, 30 Dec 2025 13:20:37 +0100 Message-ID: <2025123001-CVE-2023-54271-d75a@gregkh> X-Mailer: git-send-email 2.52.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=5530; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=NJfFiM85VnRF6EQphUkRRT0/dQveuM9MHQnjJE5NG1o=; b=owGbwMvMwCRo6H6F97bub03G02pJDJnBhwvPTN2i0fXsy4GL/pHGEzlvrc34I+mjaR15rzaJ9 yVbiV9ERywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEwk8hrDfIeMjK+xRzffiFkn Gnl+7ant84zCXBjmZxnOC1two+LZi9yGI692pz18bMLkBQA= 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: blk-cgroup: Fix NULL deref caused by blkg_policy_data being installed before init blk-iocost sometimes causes the following crash: BUG: kernel NULL pointer dereference, address: 00000000000000e0 ... RIP: 0010:_raw_spin_lock+0x17/0x30 Code: be 01 02 00 00 e8 79 38 39 ff 31 d2 89 d0 5d c3 0f 1f 00 0f 1f 44 00 00 55 48 89 e5 65 ff 05 48 d0 34 7e b9 01 00 00 00 31 c0 0f b1 0f 75 02 5d c3 89 c6 e8 ea 04 00 00 5d c3 0f 1f 84 00 00 RSP: 0018:ffffc900023b3d40 EFLAGS: 00010046 RAX: 0000000000000000 RBX: 00000000000000e0 RCX: 0000000000000001 RDX: ffffc900023b3d20 RSI: ffffc900023b3cf0 RDI: 00000000000000e0 RBP: ffffc900023b3d40 R08: ffffc900023b3c10 R09: 0000000000000003 R10: 0000000000000064 R11: 000000000000000a R12: ffff888102337000 R13: fffffffffffffff2 R14: ffff88810af408c8 R15: ffff8881070c3600 FS: 00007faaaf364fc0(0000) GS:ffff88842fdc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000000e0 CR3: 00000001097b1000 CR4: 0000000000350ea0 Call Trace: ioc_weight_write+0x13d/0x410 cgroup_file_write+0x7a/0x130 kernfs_fop_write_iter+0xf5/0x170 vfs_write+0x298/0x370 ksys_write+0x5f/0xb0 __x64_sys_write+0x1b/0x20 do_syscall_64+0x3d/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 This happens because iocg->ioc is NULL. The field is initialized by ioc_pd_init() and never cleared. The NULL deref is caused by blkcg_activate_policy() installing blkg_policy_data before initializing it. blkcg_activate_policy() was doing the following: 1. Allocate pd's for all existing blkg's and install them in blkg->pd[]. 2. Initialize all pd's. 3. Online all pd's. blkcg_activate_policy() only grabs the queue_lock and may release and re-acquire the lock as allocation may need to sleep. ioc_weight_write() grabs blkcg->lock and iterates all its blkg's. The two can race and if ioc_weight_write() runs during #1 or between #1 and #2, it can encounter a pd which is not initialized yet, leading to crash. The crash can be reproduced with the following script: #!/bin/bash echo +io > /sys/fs/cgroup/cgroup.subtree_control systemd-run --unit touch-sda --scope dd if=/dev/sda of=/dev/null bs=1M count=1 iflag=direct echo 100 > /sys/fs/cgroup/system.slice/io.weight bash -c "echo '8:0 enable=1' > /sys/fs/cgroup/io.cost.qos" & sleep .2 echo 100 > /sys/fs/cgroup/system.slice/io.weight with the following patch applied: > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c > index fc49be622e05..38d671d5e10c 100644 > --- a/block/blk-cgroup.c > +++ b/block/blk-cgroup.c > @@ -1553,6 +1553,12 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) > pd->online = false; > } > > + if (system_state == SYSTEM_RUNNING) { > + spin_unlock_irq(&q->queue_lock); > + ssleep(1); > + spin_lock_irq(&q->queue_lock); > + } > + > /* all allocated, init in the same order */ > if (pol->pd_init_fn) > list_for_each_entry_reverse(blkg, &q->blkg_list, q_node) I don't see a reason why all pd's should be allocated, initialized and onlined together. The only ordering requirement is that parent blkgs to be initialized and onlined before children, which is guaranteed from the walking order. Let's fix the bug by allocating, initializing and onlining pd for each blkg and holding blkcg->lock over initialization and onlining. This ensures that an installed blkg is always fully initialized and onlined removing the the race window. The Linux kernel CVE team has assigned CVE-2023-54271 to this issue. Affected and fixed versions =========================== Issue introduced in 5.4 with commit 9d179b865449b351ad5cb76dbea480c9170d4a27 and fixed in 6.4.16 with commit e39ef7880d1057b2ebcdb013405f4d84a257db23 Issue introduced in 5.4 with commit 9d179b865449b351ad5cb76dbea480c9170d4a27 and fixed in 6.5.3 with commit 7d63c6f9765339dcfc34b7365ced7c518012e4fe Issue introduced in 5.4 with commit 9d179b865449b351ad5cb76dbea480c9170d4a27 and fixed in 6.6 with commit ec14a87ee1999b19d8b7ed0fa95fea80644624ae 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-2023-54271 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: block/blk-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/e39ef7880d1057b2ebcdb013405f4d84a257db23 https://git.kernel.org/stable/c/7d63c6f9765339dcfc34b7365ced7c518012e4fe https://git.kernel.org/stable/c/ec14a87ee1999b19d8b7ed0fa95fea80644624ae