CVE-2025-38334: x86/sgx: Prevent attempts to reclaim poisoned pages

Published Jul 10, 2025
·
Updated

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

x86/sgx: Prevent attempts to reclaim poisoned pages

TL;DR: SGX page reclaim touches the page to copy its contents to secondary storage. SGX instructions do not gracefully handle machine checks. Despite this, the existing SGX code will try to reclaim pages that it knows are poisoned. Avoid even trying to reclaim poisoned pages.

The longer story:

Pages used by an enclave only get epcpage->poison set in archmemoryfailure() but they currently stay on sgxactivepagelist until sgxenclrelease(), with the SGXEPCPAGERECLAIMERTRACKED flag untouched.

epcpage->poison is not checked in the reclaimer logic meaning that, if other conditions are met, an attempt will be made to reclaim an EPC page that was poisoned. This is bad because 1. we don't want that page to end up added to another enclave and 2. it is likely to cause one core to shut down and the kernel to panic.

Specifically, reclaiming uses microcode operations including "EWB" which accesses the EPC page contents to encrypt and write them out to non-SGX memory. Those operations cannot handle MCEs in their accesses other than by putting the executing core into a special shutdown state (affecting both threads with HT.) The kernel will subsequently panic on the remaining cores seeing the core didn't enter MCE handler(s) in time.

Call sgxunmarkpagereclaimable() to remove the affected EPC page from sgxactivepagelist on memory error to stop it being considered for reclaiming.

Testing epcpage->poison in sgxreclaimpages() would also work but I assume it's better to add code in the less likely paths.

The affected EPC page is not added to &node->sgxpoisonpagelist until later in sgxenclrelease()->sgxfreeepcpage() when it is EREMOVEd. Membership on other lists doesn't change to avoid changing any of the lists' semantics except for sgxactivepagelist. There's a "TBD" comment in archmemoryfailure() about pre-emptive actions, the goal here is not to address everything that it may imply.

This also doesn't completely close the time window when a memory error notification will be fatal (for a not previously poisoned EPC page) -- the MCE can happen after sgxreclaimpages() has selected its candidates or even inside a microcode operation (actually easy to trigger due to the amount of time spent in them.)

The spinlock in sgxunmarkpagereclaimable() is safe because memoryfailure() runs in process context and no spinlocks are held, explicitly noted in a mm/memory-failure.c comment.

Affected Software

8 affected componentsFixes available
Linux Linux kernel
Linux Linux kernel>=5.11<6.1.142
Linux Linux kernel>=6.2<6.6.95
Linux Linux kernel>=6.7<6.12.35
Linux Linux kernel>=6.13<6.15.4
Debian Debian Linux=11.0
Microsoft cbl2 kernel 5.15.186.1-1
Microsoft azl3 kernel 6.6.92.2-2<6.6.96.1-1
6.6.96.1-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 6.6.96.1-1
  2. Configuration

    When handling the affected EPC page, call sgx_unmark_page_reclaimable() to remove that EPC page from the relevant reclaim tracking/list state so the reclaimer will not touch a page whose epc_page->poison may be set.

    Linux kernel SGX EPC page reclaim logic sgx_unmark_page_reclaimable() behavior = Call sgx_unmark_page_reclaimable() to remove the affected EPC page from the reclaim candidates so it is not reclaimed
  3. Compensating control

    Ensure that EPC page reclaim logic does not attempt to reclaim poisoned EPC pages (pages with epc_page->poison set), since SGX page reclaim uses microcode operations (including EWB) that do not gracefully handle MCEs in those accesses and can lead to kernel panic.

Event History

Jul 10, 2025
CVE Published
via MITRE·08:15 AM
Data Sourced
via MITRE·08:15 AM
Description
Data Sourced
via NVD·09:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Aug 7, 2025
Data Sourced
via Microsoft·12:00 AM
DescriptionSeverityWeaknessAffected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Updated
via Microsoft·07:00 AM
WeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2025-38334?

CVE-2025-38334 is classified as a high-severity vulnerability due to its potential impact on the integrity of SGX page reclaim operations.

2

How do I fix CVE-2025-38334?

To fix CVE-2025-38334, update your Linux kernel to the latest version where this vulnerability has been patched.

3

What systems are affected by CVE-2025-38334?

CVE-2025-38334 affects the Linux kernel, particularly systems utilizing SGX for secure enclaves.

4

What is the impact of CVE-2025-38334 on system security?

CVE-2025-38334 can lead to unauthorized access to sensitive data in SGX enclaves if exploited.

5

How can I tell if my system is vulnerable to CVE-2025-38334?

You can determine if your system is vulnerable to CVE-2025-38334 by checking if you are running an outdated version of the Linux kernel prior to the patch release.

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