CVE-2023-54271: blk-cgroup: Fix NULL deref caused by blkg_policy_data being installed before init

Published Dec 30, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

blk-cgroup: Fix NULL deref caused by blkgpolicydata being installed before init

blk-iocost sometimes causes the following crash:

BUG: kernel NULL pointer dereference, address: 00000000000000e0 ... RIP: 0010:rawspinlock+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 <f0> 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: <TASK> iocweightwrite+0x13d/0x410 cgroupfilewrite+0x7a/0x130 kernfsfopwriteiter+0xf5/0x170 vfswrite+0x298/0x370 ksyswrite+0x5f/0xb0 x64syswrite+0x1b/0x20 dosyscall64+0x3d/0x80 entrySYSCALL64afterhwframe+0x46/0xb0

This happens because iocg->ioc is NULL. The field is initialized by iocpdinit() and never cleared. The NULL deref is caused by blkcgactivatepolicy() installing blkgpolicydata before initializing it.

blkcgactivatepolicy() 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.

blkcgactivatepolicy() only grabs the queuelock and may release and re-acquire the lock as allocation may need to sleep. iocweightwrite() grabs blkcg->lock and iterates all its blkg's. The two can race and if iocweightwrite() 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.subtreecontrol 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 blkcgactivatepolicy(struct gendisk disk, const struct blkcgpolicy pol) pd->online = false; } + if (systemstate == SYSTEMRUNNING) { + spinunlockirq(&q->queuelock); + ssleep(1); + spinlockirq(&q->queuelock); + } + / all allocated, init in the same order / if (pol->pdinitfn) listforeachentryreverse(blkg, &q->blkglist, qnode)

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.

Affected Software

1 affected component
linux/kernel

Event History

Dec 30, 2025
CVE Published
via MITRE·12:16 PM
Data Sourced
via MITRE·12:16 PM
Description
Data Sourced
via NVD·01:16 PM
Description

Frequently Asked Questions

1

What is the severity of CVE-2023-54271?

CVE-2023-54271 is classified as a potentially severe vulnerability due to the risk of kernel crashes and unintended behavior.

2

How do I fix CVE-2023-54271?

To remediate CVE-2023-54271, update your Linux kernel to the latest patched version containing the fix for the vulnerability.

3

What systems are affected by CVE-2023-54271?

CVE-2023-54271 affects various versions of the Linux kernel, specifically those using blk-iocost.

4

What are the consequences of exploiting CVE-2023-54271?

Exploitation of CVE-2023-54271 can lead to a kernel NULL pointer dereference, causing system crashes.

5

How can I determine if my system is vulnerable to CVE-2023-54271?

Check the version of your Linux kernel against the versions that contain the fix for CVE-2023-54271 to determine if you are vulnerable.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203