Linux Kernel VMA Iteration and Structure Teardown Race Condition Vulnerability

Vulnerability

A race condition vulnerability has been identified in the Linux kernel's memory management subsystem, specifically within the KSM (Kernel Samepage Merging) functionality. This issue arises during the iteration over virtual memory areas (VMAs) and the teardown of memory structures. The vulnerability is present in the Linux kernel stable tree. The root cause lies in the 'exit_mmap()' function, which dismantles the VMAs and the associated maple tree while holding the mmap_lock in write mode. To address this, the 'ksm_test_exit()' function should be checked after acquiring the mmap_lock in read mode, but before the 'for_each_vma()' iterator accesses a destroyed maple tree. Failing to do so could lead to a lockdep warning by dereferencing a maple tree without the necessary external lock flag.

Impact

This vulnerability can cause a race condition that disrupts the proper management of virtual memory areas, potentially leading to undefined behavior in memory handling.

Reproduction

The vulnerability can be reproduced by triggering the 'exit_mmap()' function while the 'for_each_vma()' iterator is active. This can be done by creating a scenario where the mmap_lock is held in write mode, allowing 'exit_mmap()' to tear down the VMAs and maple tree. After the maple tree is destroyed, the 'for_each_vma()' iterator can be used, which will dereference the destroyed maple tree without the appropriate lock, creating a lockdep warning.

Remediation

Users can upgrade to the latest version of the Linux kernel where this vulnerability has been addressed.

Added: Oct 4, 2025, 4:19 PM
Updated: Oct 4, 2025, 4:19 PM

Vulnerability Rating

Custom Algorithm
spread
9.0
impact
0.6
exploitability
3.9
remediation
7.7
relevance
0.7
threat
4.8
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.