CVE-2026-99739: mm/shmem: fix truncate hang in large swap entry

Published Nov 20, 2026
·
Updated

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

mm/shmem: fix truncate hang in large swap entry

Truncating a tmpfs file or memfd to a page-aligned size inside a large swap entry can loop indefinitely in shmemundorange(). The task holds the inode lock and cannot be killed.

A large swap entry represents a whole swapped-out folio. For example, truncate a file whose pages 0-7 share one swap entry to four pages:

[ 0 1 2 3 | 4 5 6 7 ] keep | discard ^ new EOF, start = 4

isize has already been updated when boundary handling asks shmemgetpartialfolio() for page 4. Since it is swapped out, the helper calls shmemgetfolio() with SGPREAD. That rejects page 4 with -EINVAL because its starting offset equals isize. Nothing is read back.

The final scan cannot free the entry without losing pages 0-3. It skips it, restarts from start = 4, and finds it again indefinitely. An unaligned truncate avoids this particular failure because the requested page starts below isize. Folios already in the page-cache cannot trigger it as the direct lookup will return them beyond EOF.

Fix it by letting shmemgetpartialfolio() call shmemswapinfolio() directly for swap entries. This bypasses the read path's isize check, allowing the existing boundary handling to zero and split the folio. If swap-in returns a smaller folio, it also splits the swap entry so the final scan can free the entries beyond EOF. Retry the lookup if the entry changes during swap-in.

Handling swap-in allocation failures remains broken and is unchanged by this commit. Even when shmemswapinfolio() correctly returns -ENOMEM instead of -EEXIST, shmemgetpartialfolio() returns NULL and shmemundorange() skips boundary handling. If the large swap entry remains intact, truncation can still loop in the final scan, while hole punching can return without zeroing the boundary.

This may read an entire large folio back from swap while holding irwsem, only to discard part of it. Avoiding that I/O would require splitting both the swap entry and any large folio still in the swap cache. That, however, is much bigger work.

Affected Software

3 affected componentsFixes available
linux/kernel>=6.12.69<6.12.118
6.12.118
linux/kernel>=6.18.9<6.18.64
6.18.64
linux/kernel>=6.19.0<7.3.5
7.3.5

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 6.12.118
  2. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 6.18.64
  3. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 7.3.5
  4. Compensating control

    Update the Linux kernel shmem implementation so shmem_get_partial_folio() calls shmem_swapin_folio() directly for swap entries, and retry the lookup if the entry changes during swap-in.

Frequently Asked Questions

1

What systems and workloads are exposed to this hang?

Systems using the Linux kernel can be affected when a tmpfs file or memfd has a large swapped-out folio represented by one swap entry. The triggering condition requires truncating the object to a page-aligned size within that large swap entry.

2

What must happen for an attacker or local process to trigger the issue?

A local process needs to arrange for pages in a tmpfs file or memfd to share a large swap entry, have that folio swapped out, and truncate at a page-aligned boundary that retains part of the entry while discarding the remainder. An unaligned truncate does not trigger this specific failure.

3

What is the operational impact if the issue is triggered?

The truncate operation can loop indefinitely in shmem_undo_range(). The affected task holds the inode lock and cannot be killed, which can leave access involving that inode blocked.

4

Are tmpfs or memfd objects already resident in the page cache affected?

No. The described failure requires the relevant large folio to be swapped out; folios already in the page cache do not trigger it because direct lookup returns them beyond EOF.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203