KernelScan.io

HIGH

mm blkcg Writeback UAF

CVE-2026-31586

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.8HIGH

01

In the Linux kernel, the following vulnerability has been resolved: mm: blk-cgroup: fix use-after-free in cgwb_release_workfn() cgwb_release_workfn() calls css_put(wb->blkcg_css) and then later accesses wb->blkcg_css again via blkcg_unpin_online(). If css_put() drops the last reference, the blkcg can be freed asynchronously (css_free_rwork_fn -> blkcg_css_free -> kfree) before blkcg_unpin_online() dereferences the pointer to access blkcg->online_pin, resulting in a use-after-free: BUG: KASAN: slab-use-after-free in blkcg_unpin_online (./include/linux/instrumented.h:112 ./include/linux/atomic/atomic-instrumented.h:400 ./include/linux/refcount.h:389 ./include/linux/refcount.h:432 ./include/linux/refcount.h:450 block/blk-cgroup.c:1367) Write of size 4 at addr ff11000117aa6160 by task kworker/71:1/531 Workqueue: cgwb_release cgwb_release_workfn Call Trace: <TASK> blkcg_unpin_online (./include/linux/instrumented.h:112 ./include/linux/atomic/atomic-instrumented.h:400 ./include/linux/refcount.h:389 ./include/linux/refcount.h:432 ./include/linux/refcount.h:450 block/blk-cgroup.c:1367) cgwb_release_workfn (mm/backing-dev.c:629) process_scheduled_works (kernel/workqueue.c:3278 kernel/workqueue.c:3385) Freed by task 1016: kfree (./include/linux/kasan.h:235 mm/slub.c:2689 mm/slub.c:6246 mm/slub.c:6561) css_free_rwork_fn (kernel/cgroup/cgroup.c:5542) process_scheduled_works (kernel/workqueue.c:3302 kernel/workqueue.c:3385) ** Stack based on commit 66672af7a095 ("Add linux-next specific files for 20260410") I am seeing this crash sporadically in Meta fleet across multiple kernel versions. A full reproducer is available at: https://github.com/leitao/debug/blob/main/reproducers/repro_blkcg_uaf.sh (The race window is narrow. To make it easily reproducible, inject a msleep(100) between css_put() and blkcg_unpin_online() in cgwb_release_workfn(). With that delay and a KASAN-enabled kernel, the reproducer triggers the splat reliably in less than a second.) Fix this by moving blkcg_unpin_online() before css_put(), so the cgwb's CSS reference keeps the blkcg alive while blkcg_unpin_online() accesses it.

02

Engine v0.2.0

Risk summary

A use-after-free vulnerability in the kernel's block cgroup writeback release function can cause system crashes or potential privilege escalation. The bug occurs when cleaning up cgroup writeback structures, where a freed memory structure is accessed after being released. While the race window is narrow, it has been observed in production environments and can be reliably triggered with specific timing conditions.

Affectedmm/backing-dev.c

Vulnerability analysis

Root Cause: In cgwb_release_workfn(), css_put(wb->blkcg_css) is called before blkcg_unpin_online(wb->blkcg_css). If css_put() drops the last reference to the blkcg CSS, the blkcg structure can be freed asynchronously by css_free_rwork_fn before blkcg_unpin_online() attempts to access blkcg->online_pin, creating a use-after-free condition.

Attack Surface: This vulnerability is triggered through the kernel's cgroup writeback (cgwb) release mechanism, which is part of the block I/O subsystem. It requires local access and the ability to trigger cgroup cleanup operations, typically through filesystem I/O operations that involve block device writeback.

Fix Mechanism: The patch reorders the operations by moving blkcg_unpin_online() before css_put(). This ensures the CSS reference keeps the blkcg structure alive while blkcg_unpin_online() accesses it, preventing the use-after-free.

03

BranchFixed inPatch commit
5.105.10.25823acef4156c2
5.155.15.2091bd36e93b542
6.16.1.175740ba1ebb223
6.126.12.83dfc8292a1d67
6.186.18.24ea3af09eb87d
6.196.19.1450879a3c1faf
6.66.6.136115a5266749d
7.07.0.167cb119d32f3
mainline7.1-rc18f5857be99f1