CVE-2026-139438

block: use iomap_dirty_folio for block devices

Published Nov 30, 2026 CVSS n/a EPSS n/a KEV · Not listed
Description
In the Linux kernel, the following vulnerability has been resolved:

block: use iomap_dirty_folio for block devices

With CONFIG_BUFFER_HEAD=n, block devices are written back through iomap,
but def_blk_aops uses filemap_dirty_folio, which only sets PG_dirty. It
does not set the per-block dirty bits in the folio's iomap_folio_state,
so iomap_writeback_folio() finds no dirty range, submits no I/O and
clears PG_dirty, resulting in data loss.

Other iomap users set .dirty_folio to iomap_dirty_folio, which marks the
folio's blocks dirty before calling filemap_dirty_folio().

This is only observable with block size < folio size. With a single
block there is no iomap_folio_state to get out of sync and
iomap_writeback_folio() marks the whole folio dirty itself. For a
page-aligned device, this may require using the BLKBSZSET ioctl to set
the block size, which requires CAP_SYS_ADMIN. A device whose size is not
page aligned already gets a sub-page block size from
set_init_blocksize(), so no ioctl and no privilege is needed.

To reproduce, on a device with a sub-page block size, write a known
pattern with O_DIRECT, mmap the same range, store to it, msync() and
fsync(), then read it back with O_DIRECT. A reproducer is available at
[1].

[1] https://gist.github.com/tzussman/18ab05cba4b3fdc79cce0a69d1fd05b4

Analysis

AI-generated

Technical impact

A flaw in the Linux kernel causes block devices to be written back incorrectly. The kernel writes back through iomap, but the default goal code uses a function that only marks a page dirty without setting per-block dirty bits. As a result, a write‑back routine finds no dirty range, submits no I/O, clears the page dirty flag, and data is lost, without any error reported to the user.

Affected Systems

All Linux kernels compiled with CONFIG_BUFFER_HEAD=n are affected. The issue appears only when a block device’s block size is smaller than a folio, which is the case for sub‑page devices or devices that have been explicitly resized to a sub‑page block size with the BLKBSZSET ioctl. Page‑aligned devices are not vulnerable because their block size matches a folio, so the kernel handles dirty tracking correctly.

Risk and Exploitability

The EPSS score is not available and the vulnerability is not listed in the CISA KEV catalog, but it can be exploited by any user who can write to a vulnerable block device. An attacker with the ability to open the device with write permissions, such as a local user or a privileged process, can cause data loss by performing ordinary write operations. The attack requires no network connectivity and no special privileges beyond those required to write to the device. The lack of exploit data suggests that while the risk of exploitation is real, its current prevalence may be limited to environments with misconfigured block sizes.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Update the Linux kernel to a version which includes the patch that correctly marks per‑block dirty bits when writing back.
  • If an immediate kernel update is not possible, ensure all block devices use a page‑aligned block size by setting the size with the BLKBSZSET ioctl or by avoiding devices that use sub‑page block sizes.
  • Verify that any applications using direct I/O or mmap on block devices perform explicit msync() and fsync() calls to force a writeback before closing the file descriptor.

Generated by OpenCVE AI on November 30, 2026 at 22:23 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-665
Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: block: use iomap_dirty_folio for block devices With CONFIG_BUFFER_HEAD=n, block devices are written back through iomap, but def_blk_aops uses filemap_dirty_folio, which only sets PG_dirty. It does not set the per-block dirty bits in the folio's iomap_folio_state, so iomap_writeback_folio() finds no dirty range, submits no I/O and clears PG_dirty, resulting in data loss. Other iomap users set .dirty_folio to iomap_dirty_folio, which marks the folio's blocks dirty before calling filemap_dirty_folio(). This is only observable with block size < folio size. With a single block there is no iomap_folio_state to get out of sync and iomap_writeback_folio() marks the whole folio dirty itself. For a page-aligned device, this may require using the BLKBSZSET ioctl to set the block size, which requires CAP_SYS_ADMIN. A device whose size is not page aligned already gets a sub-page block size from set_init_blocksize(), so no ioctl and no privilege is needed. To reproduce, on a device with a sub-page block size, write a known pattern with O_DIRECT, mmap the same range, store to it, msync() and fsync(), then read it back with O_DIRECT. A reproducer is available at [1]. [1] https://gist.github.com/tzussman/18ab05cba4b3fdc79cce0a69d1fd05b4
Title block: use iomap_dirty_folio for block devices
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References
Weaknesses

Sources

Status
PUBLISHED
Assigner
Linux
Published
Updated
Nov 30, 2026, 1:34 PM
Reserved
Nov 30, 2026, 1:22 PM
Status
Received
Published
Nov 30, 2026, 2:19 PM
Modified
Nov 30, 2026, 2:19 PM