CVE-2026-31589: mm: call ->free_folio() directly in folio_unmap_invalidate()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
mm: call ->free_folio() directly in folio_unmap_invalidate()
We can only call filemap_free_folio() if we have a reference to (or hold a lock on) the mapping. Otherwise, we've already removed the folio from the mapping so it no longer pins the mapping and the mapping can be removed, causing a use-after-free when accessing mapping->a_ops.
Follow the same pattern as __remove_mapping() and load the free_folio function pointer before dropping the lock on the mapping. That lets us make filemap_free_folio() static as this was the only caller outside filemap.c.
The Linux kernel CVE team has assigned CVE-2026-31589 to this issue.
Affected and fixed versions
===========================
Fixed in 6.19.14 with commit b667df39d98a7a24be7c2a40ff0863dac1ad2cd7 Fixed in 7.0.1 with commit c330e65ea59c4805d6ab6757c4ddfe8c63acef31
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-31589
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/filemap.c
mm/internal.h
mm/truncate.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/b667df39d98a7a24be7c2a40ff0863dac1ad2cd7 https://git.kernel.org/stable/c/c330e65ea59c4805d6ab6757c4ddfe8c63acef31 https://git.kernel.org/stable/c/615d9bb2ccad42f9e21d837431e401db2e471195