KernelScan.io

HIGH Introduced in 6.16

f2fs RedirtyBlocks UAF

CVE-2026-89841

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 AI6.3MEDIUM

01

In the Linux kernel, the following vulnerability has been resolved: f2fs: only redirty pinned folios in redirty_blocks redirty_blocks() pins folios with read_cache_folio() and then walks the same range again with filemap_lock_folio() to redirty them and drop the references it took. Commit 5951fee46bef ("f2fs: Use a folio in redirty_blocks()") changed the second pass to a do/while loop. If read_cache_folio() fails before anything is pinned, page_idx does not advance but the cleanup loop still runs once. If readahead has already populated the failed folio in page cache, that extra iteration finds it and folio_put_refs(folio, 2) drops one reference too many. Later drop_caches or reclaim can then report "BUG: Bad page state". Only redirty the range that was pinned successfully.

02

Engine v0.6.0

Risk summary

A local attacker with CAP_SYS_ADMIN on a system with a mounted f2fs filesystem can trigger a reference count underflow in the defragmentation path, leading to use-after-free of a cached page. The corruption occurs when an internal page read fails under conditions such as memory pressure, causing a cleanup loop to release a reference it never acquired. This can result in memory corruption or a kernel panic.

Affectedfs/f2fs/file.c (f2fs filesystem)

Vulnerability analysis

A cleanup loop in the f2fs defragmentation path can drop one too many references on a cached page when an earlier page-read operation fails. The original code changed the cleanup loop to always execute at least once, so even when no pages were successfully pinned, it finds a page that readahead may have already placed in the cache and releases a reference it never acquired. This reference count underflow can cause the page to be freed while still in use, leading to memory corruption. The fix restores the loop's entry condition so only pages that were actually pinned are cleaned up. This path is reachable locally through the f2fs defragmentation ioctl, which requires CAP_SYS_ADMIN, and the corruption only occurs when the initial page read fails under conditions such as memory pressure.

03

BranchIntroducedFixed inPatch commit
6.186.166.18.51445e4a1e6025
mainline6.167.3-rc185171332742e
7.26.167.2.589c65ec3c189