GHSA-9P8G-H2H7-W4W6

Vulnerability from github – Published: 2026-11-30 15:32 – Updated: 2026-11-30 15:32
VLAI
Details

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

block: take i_rwsem for the direct I/O write fallback

Commit c0e473a0d226 ("block: fix race between set_blocksize and read paths") closed a race between set_blocksize() and block device I/O: with large sector size support, set_blocksize() can change i_blkbits and the mapping's minimum folio order while a concurrent reader still holds a folio of the old, smaller order, leading to crashes. In particular, it made blkdev_write_iter() wrap buffered writes in inode_lock_shared().

However, the direct I/O fallback path was missed in that conversion. blkdev_write_iter() passes blkdev_buffered_write() as an argument to direct_write_fallback() with no lock held. A direct write that completes only partially then finishes as a buffered write with no protection.

This can cause a BUG by racing partial direct writes against ioctl(BLKBSZSET). Writer threads issue O_DIRECT pwritev() with a two-segment iovec whose second segment is an unreadable PROT_NONE mapping. The direct path then writes the first segment, fails to pin the second, and returns short, entering the fallback. A second thread keeps toggling the second segment's protection so that some fallbacks get past fault_in_iov_iter_readable() and reach the page cache, a third thread populates the page cache with folios of the current block size via pread() and readahead(), and a fourth thread toggles the block size between 512 bytes and 64K with BLKBSZSET. The minimum folio order only moves with block sizes above PAGE_SIZE, i.e. with CONFIG_TRANSPARENT_HUGEPAGE raising BLK_MAX_BLOCK_SIZE to 64K.

On a CONFIG_DEBUG_VM kernel this yields the following BUG:

page dumped because: VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_folio_order(mapping)) kernel BUG at mm/filemap.c:858! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:__filemap_add_folio+0x860/0x8d0 Call Trace: filemap_add_folio+0xc9/0x1f0 __filemap_get_folio_mpol+0x240/0x660 iomap_write_begin+0xa87/0xd70 iomap_file_buffered_write+0x304/0x6a0 blkdev_write_iter+0x255/0x510 do_iter_readv_writev+0x23d/0x3c0 vfs_writev+0x211/0x7d0 do_pwritev+0x121/0x190 do_syscall_64+0x121/0x630 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The same workload also trips WARN_ON_ONCE(pos >= folio_pos(folio) + fsize) in iomap_trim_folio_range().

Fix this by calling blkdev_buffered_write() in the fallback path under inode_lock_shared(), matching the plain buffered-write branch. With the fix the same workload runs clean.

A short IOCB_NOWAIT direct write reaches the same fallback. Taking i_rwsem there can now block behind set_blocksize(), and the fallback already blocks on writeback of the data it copied in direct_write_fallback(). blkdev_write_iter() already rejects a purely buffered IOCB_NOWAIT write with -EOPNOTSUPP, so do not enter the fallback for IOCB_NOWAIT at all: return the bytes the direct path already wrote, or -EAGAIN if none, and let the caller retry.

The reproducer used was written by an LLM, and is available at [1].

[1] https://gist.github.com/tzussman/69d06bc57d42a42989eb038b1b5aeb74

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2026-139437"
  ],
  "database_specific": {
    "cwe_ids": [],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-11-30T14:19:13Z",
    "severity": null
  },
  "details": "In the Linux kernel, the following vulnerability has been resolved:\n\nblock: take i_rwsem for the direct I/O write fallback\n\nCommit c0e473a0d226 (\"block: fix race between set_blocksize and read\npaths\") closed a race between set_blocksize() and block device I/O: with\nlarge sector size support, set_blocksize() can change i_blkbits and the\nmapping\u0027s minimum folio order while a concurrent reader still holds a\nfolio of the old, smaller order, leading to crashes. In particular, it\nmade blkdev_write_iter() wrap buffered writes in inode_lock_shared().\n\nHowever, the direct I/O fallback path was missed in that conversion.\nblkdev_write_iter() passes blkdev_buffered_write() as an argument to\ndirect_write_fallback() with no lock held. A direct write that completes\nonly partially then finishes as a buffered write with no protection.\n\nThis can cause a BUG by racing partial direct writes against\nioctl(BLKBSZSET). Writer threads issue O_DIRECT pwritev() with a\ntwo-segment iovec whose second segment is an unreadable PROT_NONE\nmapping. The direct path then writes the first segment, fails to pin the\nsecond, and returns short, entering the fallback. A second thread keeps\ntoggling the second segment\u0027s protection so that some fallbacks get past\nfault_in_iov_iter_readable() and reach the page cache, a third thread\npopulates the page cache with folios of the current block size via\npread() and readahead(), and a fourth thread toggles the block size\nbetween 512 bytes and 64K with BLKBSZSET. The minimum folio order only\nmoves with block sizes above PAGE_SIZE, i.e. with\nCONFIG_TRANSPARENT_HUGEPAGE raising BLK_MAX_BLOCK_SIZE to 64K.\n\nOn a CONFIG_DEBUG_VM kernel this yields the following BUG:\n\n  page dumped because: VM_BUG_ON_FOLIO(folio_order(folio) \u003c mapping_min_folio_order(mapping))\n  kernel BUG at mm/filemap.c:858!\n  Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI\n  RIP: 0010:__filemap_add_folio+0x860/0x8d0\n  Call Trace:\n   filemap_add_folio+0xc9/0x1f0\n   __filemap_get_folio_mpol+0x240/0x660\n   iomap_write_begin+0xa87/0xd70\n   iomap_file_buffered_write+0x304/0x6a0\n   blkdev_write_iter+0x255/0x510\n   do_iter_readv_writev+0x23d/0x3c0\n   vfs_writev+0x211/0x7d0\n   do_pwritev+0x121/0x190\n   do_syscall_64+0x121/0x630\n   entry_SYSCALL_64_after_hwframe+0x77/0x7f\n\nThe same workload also trips WARN_ON_ONCE(pos \u003e= folio_pos(folio) +\nfsize) in iomap_trim_folio_range().\n\nFix this by calling blkdev_buffered_write() in the fallback path under\ninode_lock_shared(), matching the plain buffered-write branch. With the\nfix the same workload runs clean.\n\nA short IOCB_NOWAIT direct write reaches the same fallback. Taking\ni_rwsem there can now block behind set_blocksize(), and the fallback\nalready blocks on writeback of the data it copied in\ndirect_write_fallback(). blkdev_write_iter() already rejects a purely\nbuffered IOCB_NOWAIT write with -EOPNOTSUPP, so do not enter the\nfallback for IOCB_NOWAIT at all: return the bytes the direct path\nalready wrote, or -EAGAIN if none, and let the caller retry.\n\nThe reproducer used was written by an LLM, and is available at [1].\n\n[1] https://gist.github.com/tzussman/69d06bc57d42a42989eb038b1b5aeb74",
  "id": "GHSA-9p8g-h2h7-w4w6",
  "modified": "2026-11-30T15:32:31Z",
  "published": "2026-11-30T15:32:31Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-139437"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/2fec4fd97cc3ce32283aac03b6882d3d36cbd4bb"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/ba3c9856f9851931388c38d3b57c6b95feefa062"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/c67b378879e04c6f9dbd2a122300c525586c2f62"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.