Skip to contentSkip to conversation

CVE-2026-23097: migrate: correct lock ordering for hugetlb file folios

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Feb 4

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

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

migrate: correct lock ordering for hugetlb file folios

Syzbot has found a deadlock (analyzed by Lance Yang):

1) Task (5749): Holds folio_lock, then tries to acquire i_mmap_rwsem(read lock).
2) Task (5754): Holds i_mmap_rwsem(write lock), then tries to acquire folio_lock.

migrate_pages()
-> migrate_hugetlbs()

    -> unmap_and_move_huge_page()     <- Takes folio_lock!
      -> remove_migration_ptes()
        -> __rmap_walk_file()
          -> i_mmap_lock_read()       <- Waits for i_mmap_rwsem(read lock)!

hugetlbfs_fallocate()
-> hugetlbfs_punch_hole() <- Takes i_mmap_rwsem(write lock)!

    -> hugetlbfs_zero_partial_page()
     -> filemap_lock_hugetlb_folio()
      -> filemap_lock_folio()
        -> __filemap_get_folio        <- Waits for folio_lock!

The migration path is the one taking locks in the wrong order according to the documentation at the top of mm/rmap.c. So expand the scope of the existing i_mmap_lock to cover the calls to remove_migration_ptes() too.

This is (mostly) how it used to be after commit c0d0381ade79. That was removed by 336bf30eb765 for both file & anon hugetlb pages when it should only have been removed for anon hugetlb pages.

The Linux kernel CVE team has assigned CVE-2026-23097 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.10 with commit 336bf30eb76580b579dc711ded5d599d905c0217 and fixed in 6.6.122 with commit 526394af4e8ade89cacd1a9ce2b97712712fcc34
	Issue introduced in 5.10 with commit 336bf30eb76580b579dc711ded5d599d905c0217 and fixed in 6.12.68 with commit b75070823b89009f5123fd0e05a8e0c3d39937c1
	Issue introduced in 5.10 with commit 336bf30eb76580b579dc711ded5d599d905c0217 and fixed in 6.18.8 with commit 1b68efce6dd483d22f50d0d3800c4cfda14b1305
	Issue introduced in 5.10 with commit 336bf30eb76580b579dc711ded5d599d905c0217 and fixed in 6.19-rc7 with commit b7880cb166ab62c2409046b2347261abf701530e
	Issue introduced in 5.9.9 with commit ef792d6ce0db6a56e56743b1de1716a982c3b851

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2026-23097

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
mm/migrate.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/526394af4e8ade89cacd1a9ce2b97712712fcc34
	https://git.kernel.org/stable/c/b75070823b89009f5123fd0e05a8e0c3d39937c1
	https://git.kernel.org/stable/c/1b68efce6dd483d22f50d0d3800c4cfda14b1305
	https://git.kernel.org/stable/c/b7880cb166ab62c2409046b2347261abf701530e