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

f2fs: fix use-after-free of sbi in f2fs_compress_write_end_io()

In f2fs_compress_write_end_io(), dec_page_count(sbi, type) can bring
the F2FS_WB_CP_DATA counter to zero, unblocking
f2fs_wait_on_all_pages() in f2fs_put_super() on a concurrent unmount
CPU. The unmount path then proceeds to call
f2fs_destroy_page_array_cache(sbi), which destroys
sbi->page_array_slab via kmem_cache_destroy(), and eventually
kfree(sbi). Meanwhile, the bio completion callback is still executing:
when it reaches page_array_free(sbi, ...), it dereferences
sbi->page_array_slab — a destroyed slab cache — to call
kmem_cache_free(), causing a use-after-free.

This is the same class of bug as CVE-2026-23234 (which fixed the
equivalent race in f2fs_write_end_io() in data.c), but in the
compressed writeback completion path that was not covered by that fix.

Fix this by moving dec_page_count() to after page_array_free(), so
that all sbi accesses complete before the counter decrement that can
unblock unmount. For non-last folios (where atomic_dec_return on
cic->pending_pages is nonzero), dec_page_count is called immediately
before returning — page_array_free is not reached on this path, so
there is no post-decrement sbi access. For the last folio,
page_array_free runs while the F2FS_WB_CP_DATA counter is still
nonzero (this folio has not yet decremented it), keeping sbi alive,
and dec_page_count runs as the final operation.
Published: 2026-05-01
Score: n/a
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

A race condition in the f2fs filesystem allows a use‑after‑free of the superblock information (sbi) structure during the completion of compressed writeback operations. The bug occurs when the write‑back path decrements a counter that can unblock an unmount, which in turn frees the sbi before the write‑back callback finishes. The callback then accesses freed memory. This memory corruption can lead to unpredictable kernel behavior, crashes, or, if an attacker can trigger the scenario, arbitrary code execution in kernel mode. The vulnerability is specific to the f2fs_compress_write_end_io() routine and is similar to a previously fixed race in f2fs_write_end_io(). Based on the description, it is inferred that the race can be induced by coordinating writeback and unmount operations, which may require local access.

Affected Systems

All Linux kernel releases that contain f2fs before the patch that moves the dec_page_count() call after page_array_free(). The affected code path is part of the f2fs filesystem layer and affects all systems using compiled‑in or dynamically loaded f2fs modules.

Risk and Exploitability

No CVSS score or EPSS information is published for this vulnerability, and it is not listed in the CISA KEV catalog. The attack requires a local context that can exploit a race between compressed writeback and filesystem unmounts; it is therefore not publicly exploitable in a remote scenario. However, the use‑after‑free could allow privilege escalation to root or cause denial of service if an attacker can arrange the conditions. Based on the description, the vulnerability likely requires local execution privileges and is not a feasible remote attack vector. The overall risk is considered moderate to high for environments that rely on f2fs and perform unmounts while writeback is active.

Generated by OpenCVE AI on May 2, 2026 at 07:43 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the Linux kernel to a version that includes the fix for f2fs_compress_write_end_io()
  • Before unmounting an f2fs filesystem, run a sync or fsync to ensure all pending writes are completed
  • If a patch is unavailable, avoid unmounting while the filesystem is actively performing compressed writeback; consider disabling compressed writes if possible

Generated by OpenCVE AI on May 2, 2026 at 07:43 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Sat, 02 May 2026 00:15:00 +0000


Fri, 01 May 2026 14:15:00 +0000

Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: f2fs: fix use-after-free of sbi in f2fs_compress_write_end_io() In f2fs_compress_write_end_io(), dec_page_count(sbi, type) can bring the F2FS_WB_CP_DATA counter to zero, unblocking f2fs_wait_on_all_pages() in f2fs_put_super() on a concurrent unmount CPU. The unmount path then proceeds to call f2fs_destroy_page_array_cache(sbi), which destroys sbi->page_array_slab via kmem_cache_destroy(), and eventually kfree(sbi). Meanwhile, the bio completion callback is still executing: when it reaches page_array_free(sbi, ...), it dereferences sbi->page_array_slab — a destroyed slab cache — to call kmem_cache_free(), causing a use-after-free. This is the same class of bug as CVE-2026-23234 (which fixed the equivalent race in f2fs_write_end_io() in data.c), but in the compressed writeback completion path that was not covered by that fix. Fix this by moving dec_page_count() to after page_array_free(), so that all sbi accesses complete before the counter decrement that can unblock unmount. For non-last folios (where atomic_dec_return on cic->pending_pages is nonzero), dec_page_count is called immediately before returning — page_array_free is not reached on this path, so there is no post-decrement sbi access. For the last folio, page_array_free runs while the F2FS_WB_CP_DATA counter is still nonzero (this folio has not yet decremented it), keeping sbi alive, and dec_page_count runs as the final operation.
Title f2fs: fix use-after-free of sbi in f2fs_compress_write_end_io()
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References

Subscriptions

Linux Linux Kernel
cve-icon MITRE

Status: PUBLISHED

Assigner: Linux

Published:

Updated: 2026-05-01T13:56:01.601Z

Reserved: 2026-03-09T15:48:24.132Z

Link: CVE-2026-31702

cve-icon Vulnrichment

No data.

cve-icon NVD

Status : Awaiting Analysis

Published: 2026-05-01T14:16:20.140

Modified: 2026-05-01T15:24:14.893

Link: CVE-2026-31702

cve-icon Redhat

Severity :

Publid Date: 2026-05-01T00:00:00Z

Links: CVE-2026-31702 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-05-02T07:45:37Z

Weaknesses