{"api_version":"1","generated_at":"2026-11-30T16:05:44+00:00","cve":"CVE-2026-139437","urls":{"html":"https://cve.report/CVE-2026-139437","api":"https://cve.report/api/cve/CVE-2026-139437.json","docs":"https://cve.report/api","cve_org":"https://www.cve.org/CVERecord?id=CVE-2026-139437","nvd":"https://nvd.nist.gov/vuln/detail/CVE-2026-139437"},"summary":{"title":"block: take i_rwsem for the direct I/O write fallback","description":"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's 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's 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) < 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 >= 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","state":"PUBLISHED","assigner":"Linux","published_at":"2026-11-30 14:19:13","updated_at":"2026-11-30 14:19:13"},"problem_types":[],"metrics":[],"references":[{"url":"https://git.kernel.org/stable/c/ba3c9856f9851931388c38d3b57c6b95feefa062","name":"https://git.kernel.org/stable/c/ba3c9856f9851931388c38d3b57c6b95feefa062","refsource":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","tags":[],"title":"","mime":"","httpstatus":"","archivestatus":"0"},{"url":"https://git.kernel.org/stable/c/2fec4fd97cc3ce32283aac03b6882d3d36cbd4bb","name":"https://git.kernel.org/stable/c/2fec4fd97cc3ce32283aac03b6882d3d36cbd4bb","refsource":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","tags":[],"title":"","mime":"","httpstatus":"","archivestatus":"0"},{"url":"https://git.kernel.org/stable/c/c67b378879e04c6f9dbd2a122300c525586c2f62","name":"https://git.kernel.org/stable/c/c67b378879e04c6f9dbd2a122300c525586c2f62","refsource":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","tags":[],"title":"","mime":"","httpstatus":"","archivestatus":"0"},{"url":"https://www.cve.org/CVERecord?id=CVE-2026-139437","name":"CVE Program record","refsource":"CVE.ORG","tags":["canonical"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139437","name":"NVD vulnerability detail","refsource":"NVD","tags":["canonical","analysis"]}],"affected":[{"source":"CNA","vendor":"Linux","product":"Linux","version":"affected 3c20917120ce61f2a123ca0810293872f4c6b5a4 c67b378879e04c6f9dbd2a122300c525586c2f62 git","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"affected 3c20917120ce61f2a123ca0810293872f4c6b5a4 ba3c9856f9851931388c38d3b57c6b95feefa062 git","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"affected 3c20917120ce61f2a123ca0810293872f4c6b5a4 2fec4fd97cc3ce32283aac03b6882d3d36cbd4bb git","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"affected 6.15","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"unaffected 6.15 semver","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"unaffected 6.18.65 6.18.* semver","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"unaffected 7.3.6 7.3.* semver","platforms":[]},{"source":"CNA","vendor":"Linux","product":"Linux","version":"unaffected 7.4-rc1 * original_commit_for_fix","platforms":[]}],"timeline":[],"solutions":[],"workarounds":[],"exploits":[],"credits":[],"nvd_cpes":[],"vendor_comments":[],"enrichments":{"kev":null,"epss":null,"legacy_qids":[]},"source_records":{"cve_program":{"containers":{"cna":{"affected":[{"defaultStatus":"unaffected","product":"Linux","programFiles":["block/fops.c"],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","vendor":"Linux","versions":[{"lessThan":"c67b378879e04c6f9dbd2a122300c525586c2f62","status":"affected","version":"3c20917120ce61f2a123ca0810293872f4c6b5a4","versionType":"git"},{"lessThan":"ba3c9856f9851931388c38d3b57c6b95feefa062","status":"affected","version":"3c20917120ce61f2a123ca0810293872f4c6b5a4","versionType":"git"},{"lessThan":"2fec4fd97cc3ce32283aac03b6882d3d36cbd4bb","status":"affected","version":"3c20917120ce61f2a123ca0810293872f4c6b5a4","versionType":"git"}]},{"defaultStatus":"affected","product":"Linux","programFiles":["block/fops.c"],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","vendor":"Linux","versions":[{"status":"affected","version":"6.15"},{"lessThan":"6.15","status":"unaffected","version":"0","versionType":"semver"},{"lessThanOrEqual":"6.18.*","status":"unaffected","version":"6.18.65","versionType":"semver"},{"lessThanOrEqual":"7.3.*","status":"unaffected","version":"7.3.6","versionType":"semver"},{"lessThanOrEqual":"*","status":"unaffected","version":"7.4-rc1","versionType":"original_commit_for_fix"}]}],"cpeApplicability":[{"nodes":[{"cpeMatch":[{"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionEndExcluding":"6.18.65","versionStartIncluding":"6.15","vulnerable":true},{"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionEndExcluding":"7.3.6","versionStartIncluding":"6.15","vulnerable":true},{"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionEndExcluding":"7.4-rc1","versionStartIncluding":"6.15","vulnerable":true}],"negate":false,"operator":"OR"}]}],"descriptions":[{"lang":"en","value":"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's 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's 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) < 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 >= 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"}],"providerMetadata":{"dateUpdated":"2026-11-30T13:34:44.926Z","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","shortName":"Linux"},"references":[{"url":"https://git.kernel.org/stable/c/c67b378879e04c6f9dbd2a122300c525586c2f62"},{"url":"https://git.kernel.org/stable/c/ba3c9856f9851931388c38d3b57c6b95feefa062"},{"url":"https://git.kernel.org/stable/c/2fec4fd97cc3ce32283aac03b6882d3d36cbd4bb"}],"title":"block: take i_rwsem for the direct I/O write fallback","x_generator":{"engine":"bippy-1.2.0"}}},"cveMetadata":{"assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","assignerShortName":"Linux","cveId":"CVE-2026-139437","datePublished":"2026-11-30T13:34:44.926Z","dateReserved":"2026-11-30T13:22:15.933Z","dateUpdated":"2026-11-30T13:34:44.926Z","state":"PUBLISHED"},"dataType":"CVE_RECORD","dataVersion":"5.2"},"nvd":{"publishedDate":"2026-11-30 14:19:13","lastModifiedDate":"2026-11-30 14:19:13","problem_types":[],"metrics":[],"configurations":[]},"legacy_mitre":{"record":{"CveYear":"2026","CveId":"139437","Ordinal":"1","Title":"block: take i_rwsem for the direct I/O write fallback","CVE":"CVE-2026-139437","Year":"2026"},"notes":[{"CveYear":"2026","CveId":"139437","Ordinal":"1","NoteData":"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's 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's 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) < 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 >= 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","Type":"Description","Title":"block: take i_rwsem for the direct I/O write fallback"}]}}}