CVE-2024-26759: Vulnerability in Linux Linux
In the Linux kernel, the following vulnerability has been resolved: mm/swap: fix race when skipping swapcache When skipping swapcache for SWP_SYNCHRONOUS_IO, if two or more threads swapin the same entry at the same time, they get different pages (A, B). Before one thread (T0) finishes the swapin and installs page (A) to the PTE, another thread (T1) could finish swapin of page (B), swap_free the entry, then swap out the possibly modified page reusing the same entry. It breaks the pte_same check in (T0) because PTE value is unchanged, causing ABA problem. Thread (T0) will install a stalled page (A) into the PTE and cause data corruption. One possible callstack is like this: CPU0 CPU1 ---- ---- do_swap_page() do_swap_page() with same entry <direct swapin path> <direct swapin path> <alloc page A> <alloc page B> swap_read_folio() <- read to page A swap_read_folio() <- read to page B <slow on later locks or interrupt> <finished swapin first> ... set_pte_at() swap_free() <- entry is free <write to page B, now page A stalled> <swap out page B to same swap entry> pte_same() <- Check pass, PTE seems unchanged, but page A is stalled! swap_free() <- page B content lost! set_pte_at() <- staled page A installed! And besides, for ZRAM, swap_free() allows the swap device to discard the entry content, so even if page (B) is not modified, if swap_read_folio() on CPU0 happens later than swap_free() on CPU1, it may also cause data loss. To fix this, reuse swapcache_prepare which will pin the swap entry using the cache flag, and allow only one thread to swap it in, also prevent any parallel code from putting the entry in the cache. Release the pin after PT unlocked. Racers just loop and wait since it's a rare and very short event. A schedule_timeout_uninterruptible(1) call is added to avoid repeated page faults wasting too much CPU, causing livelock or adding too much noise to perf statistics. A similar livelock issue was described in commit 029c4628b2eb ("mm: swap: get rid of livelock in swapin readahead") Reproducer: This race issue can be triggered easily using a well constructed reproducer and patched brd (with a delay in read path) [1]: With latest 6.8 mainline, race caused data loss can be observed easily: $ gcc -g -lpthread test-thread-swap-race.c && ./a.out Polulating 32MB of memory region... Keep swapping out... Starting round 0... Spawning 65536 workers... 32746 workers spawned, wait for done... Round 0: Error on 0x5aa00, expected 32746, got 32743, 3 data loss! Round 0: Error on 0x395200, expected 32746, got 32743, 3 data loss! Round 0: Error on 0x3fd000, expected 32746, got 32737, 9 data loss! Round 0 Failed, 15 data loss! This reproducer spawns multiple threads sharing the same memory region using a small swap device. Every two threads updates mapped pages one by one in opposite direction trying to create a race, with one dedicated thread keep swapping out the data out using madvise. The reproducer created a reproduce rate of about once every 5 minutes, so the race should be totally possible in production. After this patch, I ran the reproducer for over a few hundred rounds and no data loss observed. Performance overhead is minimal, microbenchmark swapin 10G from 32G zram: Before: 10934698 us After: 11157121 us Cached: 13155355 us (Dropping SWP_SYNCHRONOUS_IO flag) [kasong@tencent.com: v4]
AI Analysis
Technical Summary
CVE-2024-26759 is a race condition vulnerability in the Linux kernel's memory management subsystem, specifically within the swap cache handling code. The flaw occurs when multiple threads concurrently swap in the same swap entry under the SWP_SYNCHRONOUS_IO flag. In this scenario, two or more threads may allocate different pages (A and B) for the same swap entry and proceed with swap-in operations simultaneously. Due to a race, one thread (T1) may complete its swap-in first, free the swap entry, and then swap out a possibly modified page reusing the same swap entry. Meanwhile, another thread (T0) that started earlier but finished later installs a stale page (A) into the page table entry (PTE), bypassing the pte_same check because the PTE value appears unchanged. This results in data corruption and potential data loss. The issue is exacerbated in ZRAM devices, where swap_free() can discard the entry content, causing data loss even if the page was not modified. The vulnerability arises from an ABA problem in the swapcache management and improper synchronization between threads accessing the same swap entry. The fix involves reusing swapcache_prepare to pin the swap entry, ensuring only one thread can swap it in at a time and preventing parallel cache insertions. Threads that race wait in a loop with a short uninterruptible sleep to avoid livelock and excessive CPU usage. A reproducer demonstrates the vulnerability by spawning tens of thousands of threads swapping the same memory region, causing observable data loss every few minutes. The patch eliminates data loss with minimal performance overhead (~2% increase in swap-in latency). This vulnerability affects Linux kernel versions prior to the patch and is relevant to systems using swap, including those with ZRAM compressed swap devices. No known exploits are reported in the wild yet.
Potential Impact
For European organizations, this vulnerability poses a significant risk to data integrity on Linux-based systems that utilize swap space, especially those employing ZRAM or other compressed swap devices. Data corruption or loss could affect critical applications relying on memory paging, such as database servers, virtualization hosts, and high-performance computing clusters. The race condition could lead to silent data corruption, making detection difficult and potentially causing application crashes, incorrect computations, or system instability. Organizations with large-scale Linux deployments, including cloud providers, financial institutions, research centers, and government agencies, could face operational disruptions and data integrity issues. The vulnerability does not directly enable privilege escalation or remote code execution but undermines system reliability and data correctness, which are critical for compliance with data protection regulations like GDPR. Additionally, the subtle nature of the bug may complicate forensic analysis and incident response. Systems under heavy multi-threaded load with frequent swapping are at higher risk. While no active exploitation is known, the vulnerability's presence in mainline Linux kernels and its reproducibility indicate a credible threat to data integrity in production environments.
Mitigation Recommendations
European organizations should prioritize applying the official Linux kernel patch that addresses CVE-2024-26759 as soon as possible. Kernel updates from trusted Linux distributions (e.g., Debian, Ubuntu, Red Hat, SUSE) should be monitored and deployed promptly. For environments where immediate patching is not feasible, organizations can mitigate risk by reducing swap usage or disabling swap temporarily, especially on systems with high concurrency and swap activity. Monitoring tools should be enhanced to detect unusual swap-related errors or data corruption symptoms. Testing the patch in staging environments with workloads that heavily utilize swap can validate stability and performance impact before production rollout. For systems using ZRAM, verifying that the patched kernel version is deployed is critical due to the increased risk of data loss. Additionally, organizations should review multi-threaded applications that perform intensive memory operations and consider workload adjustments to minimize concurrent swap-in races. Backup and data integrity verification processes should be strengthened to detect and recover from potential silent data corruption. Finally, security teams should stay alert for any emerging exploit reports or proof-of-concept code that might appear in the wild.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Finland, Poland, Italy, Spain
CVE-2024-26759: Vulnerability in Linux Linux
Description
In the Linux kernel, the following vulnerability has been resolved: mm/swap: fix race when skipping swapcache When skipping swapcache for SWP_SYNCHRONOUS_IO, if two or more threads swapin the same entry at the same time, they get different pages (A, B). Before one thread (T0) finishes the swapin and installs page (A) to the PTE, another thread (T1) could finish swapin of page (B), swap_free the entry, then swap out the possibly modified page reusing the same entry. It breaks the pte_same check in (T0) because PTE value is unchanged, causing ABA problem. Thread (T0) will install a stalled page (A) into the PTE and cause data corruption. One possible callstack is like this: CPU0 CPU1 ---- ---- do_swap_page() do_swap_page() with same entry <direct swapin path> <direct swapin path> <alloc page A> <alloc page B> swap_read_folio() <- read to page A swap_read_folio() <- read to page B <slow on later locks or interrupt> <finished swapin first> ... set_pte_at() swap_free() <- entry is free <write to page B, now page A stalled> <swap out page B to same swap entry> pte_same() <- Check pass, PTE seems unchanged, but page A is stalled! swap_free() <- page B content lost! set_pte_at() <- staled page A installed! And besides, for ZRAM, swap_free() allows the swap device to discard the entry content, so even if page (B) is not modified, if swap_read_folio() on CPU0 happens later than swap_free() on CPU1, it may also cause data loss. To fix this, reuse swapcache_prepare which will pin the swap entry using the cache flag, and allow only one thread to swap it in, also prevent any parallel code from putting the entry in the cache. Release the pin after PT unlocked. Racers just loop and wait since it's a rare and very short event. A schedule_timeout_uninterruptible(1) call is added to avoid repeated page faults wasting too much CPU, causing livelock or adding too much noise to perf statistics. A similar livelock issue was described in commit 029c4628b2eb ("mm: swap: get rid of livelock in swapin readahead") Reproducer: This race issue can be triggered easily using a well constructed reproducer and patched brd (with a delay in read path) [1]: With latest 6.8 mainline, race caused data loss can be observed easily: $ gcc -g -lpthread test-thread-swap-race.c && ./a.out Polulating 32MB of memory region... Keep swapping out... Starting round 0... Spawning 65536 workers... 32746 workers spawned, wait for done... Round 0: Error on 0x5aa00, expected 32746, got 32743, 3 data loss! Round 0: Error on 0x395200, expected 32746, got 32743, 3 data loss! Round 0: Error on 0x3fd000, expected 32746, got 32737, 9 data loss! Round 0 Failed, 15 data loss! This reproducer spawns multiple threads sharing the same memory region using a small swap device. Every two threads updates mapped pages one by one in opposite direction trying to create a race, with one dedicated thread keep swapping out the data out using madvise. The reproducer created a reproduce rate of about once every 5 minutes, so the race should be totally possible in production. After this patch, I ran the reproducer for over a few hundred rounds and no data loss observed. Performance overhead is minimal, microbenchmark swapin 10G from 32G zram: Before: 10934698 us After: 11157121 us Cached: 13155355 us (Dropping SWP_SYNCHRONOUS_IO flag) [kasong@tencent.com: v4]
AI-Powered Analysis
Technical Analysis
CVE-2024-26759 is a race condition vulnerability in the Linux kernel's memory management subsystem, specifically within the swap cache handling code. The flaw occurs when multiple threads concurrently swap in the same swap entry under the SWP_SYNCHRONOUS_IO flag. In this scenario, two or more threads may allocate different pages (A and B) for the same swap entry and proceed with swap-in operations simultaneously. Due to a race, one thread (T1) may complete its swap-in first, free the swap entry, and then swap out a possibly modified page reusing the same swap entry. Meanwhile, another thread (T0) that started earlier but finished later installs a stale page (A) into the page table entry (PTE), bypassing the pte_same check because the PTE value appears unchanged. This results in data corruption and potential data loss. The issue is exacerbated in ZRAM devices, where swap_free() can discard the entry content, causing data loss even if the page was not modified. The vulnerability arises from an ABA problem in the swapcache management and improper synchronization between threads accessing the same swap entry. The fix involves reusing swapcache_prepare to pin the swap entry, ensuring only one thread can swap it in at a time and preventing parallel cache insertions. Threads that race wait in a loop with a short uninterruptible sleep to avoid livelock and excessive CPU usage. A reproducer demonstrates the vulnerability by spawning tens of thousands of threads swapping the same memory region, causing observable data loss every few minutes. The patch eliminates data loss with minimal performance overhead (~2% increase in swap-in latency). This vulnerability affects Linux kernel versions prior to the patch and is relevant to systems using swap, including those with ZRAM compressed swap devices. No known exploits are reported in the wild yet.
Potential Impact
For European organizations, this vulnerability poses a significant risk to data integrity on Linux-based systems that utilize swap space, especially those employing ZRAM or other compressed swap devices. Data corruption or loss could affect critical applications relying on memory paging, such as database servers, virtualization hosts, and high-performance computing clusters. The race condition could lead to silent data corruption, making detection difficult and potentially causing application crashes, incorrect computations, or system instability. Organizations with large-scale Linux deployments, including cloud providers, financial institutions, research centers, and government agencies, could face operational disruptions and data integrity issues. The vulnerability does not directly enable privilege escalation or remote code execution but undermines system reliability and data correctness, which are critical for compliance with data protection regulations like GDPR. Additionally, the subtle nature of the bug may complicate forensic analysis and incident response. Systems under heavy multi-threaded load with frequent swapping are at higher risk. While no active exploitation is known, the vulnerability's presence in mainline Linux kernels and its reproducibility indicate a credible threat to data integrity in production environments.
Mitigation Recommendations
European organizations should prioritize applying the official Linux kernel patch that addresses CVE-2024-26759 as soon as possible. Kernel updates from trusted Linux distributions (e.g., Debian, Ubuntu, Red Hat, SUSE) should be monitored and deployed promptly. For environments where immediate patching is not feasible, organizations can mitigate risk by reducing swap usage or disabling swap temporarily, especially on systems with high concurrency and swap activity. Monitoring tools should be enhanced to detect unusual swap-related errors or data corruption symptoms. Testing the patch in staging environments with workloads that heavily utilize swap can validate stability and performance impact before production rollout. For systems using ZRAM, verifying that the patched kernel version is deployed is critical due to the increased risk of data loss. Additionally, organizations should review multi-threaded applications that perform intensive memory operations and consider workload adjustments to minimize concurrent swap-in races. Backup and data integrity verification processes should be strengthened to detect and recover from potential silent data corruption. Finally, security teams should stay alert for any emerging exploit reports or proof-of-concept code that might appear in the wild.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- Linux
- Date Reserved
- 2024-02-19T14:20:24.170Z
- Cisa Enriched
- true
- Cvss Version
- null
- State
- PUBLISHED
Threat ID: 682d982ac4522896dcbe3a9d
Added to database: 5/21/2025, 9:08:58 AM
Last enriched: 6/29/2025, 6:12:36 PM
Last updated: 8/18/2025, 11:25:09 PM
Views: 21
Related Threats
CVE-2025-9137: Cross Site Scripting in Scada-LTS
MediumCVE-2025-9136: Out-of-Bounds Read in libretro RetroArch
MediumCVE-2025-9135: Improper Export of Android Application Components in Verkehrsauskunft Österreich SmartRide
MediumCVE-2025-8783: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in kleor Contact Manager
MediumTrivial C# Random Exploitation
HighActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.