Skip to content

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

MediumCVSS 5.5 EPSS 0.18%
Published
Updated
Exploit status
No public exploit known
CISA SSVC
No known exploitation · automatable: no · technical impact: partial
Technology
Linux KernelUbuntuDebian

Description

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 epc_page->poison set in
arch_memory_failure() but they currently stay on sgx_active_page_list until
sgx_encl_release(), with the SGX_EPC_PAGE_RECLAIMER_TRACKED flag untouched.

epc_page->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 sgx_unmark_page_reclaimable() to remove the affected EPC page from
sgx_active_page_list on memory error to stop it being considered for
reclaiming.

Testing epc_page->poison in sgx_reclaim_pages() 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->sgx_poison_page_list until
later in sgx_encl_release()->sgx_free_epc_page() when it is EREMOVEd.
Membership on other lists doesn't change to avoid changing any of the
lists' semantics except for sgx_active_page_list. There's a "TBD" comment
in arch_memory_failure() 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 sgx_reclaim_pages() 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 sgx_unmark_page_reclaimable() is safe because
memory_failure() runs in process context and no spinlocks are held,
explicitly noted in a mm/memory-failure.c comment.

Upgrade path

13 packages: 7 fixed, 5 with no fix yet.

PackageAffectedFixed inStatus
cbl-mariner kernel(CBL-Mariner 2.0) All versions No fix listed No fix yet
Microsoft cbl2 kernel 5.15.202.1-1 All versions No fix listed No fix yet
ubuntu/linux(Ubuntu 22.04) All versions No fix listed No fix yet
ubuntu/linux-kvm(Ubuntu 22.04) All versions No fix listed No fix yet
ubuntu/linux-raspi(Ubuntu 22.04) All versions No fix listed No fix yet
azure linux kernel(Azure Linux 3.0) < 6.6.96.1-1 6.6.96.1-1 Fixed
debian/linux(Debian 12) < 6.1.147-1; = 6.1.27-1; = 6.1.37-1; = 6.1.38-1 +38 more 6.1.147-1 Fixed
debian/linux(Debian 13) < 6.12.35-1 6.12.35-1 Fixed
debian/linux(Debian 14) < 6.12.35-1 6.12.35-1 Fixed
Linux kernel < 6.1.142; < 6.6.95; < 6.12.35; < 6.15.4 +11 more 00a88e9ea1b170d579c56327c38f7e8cf689df87, 6.1.142, 6.6.95, 6.12.35, 6.15.4, 6.16, 31dcbac94bfeabb86bf85b0c36803fdd6536437b, 62b62a2a6dc51ed6e8e334861f04220c9cf8106a, dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe, ed16618c380c32c68c06186d0ccbb0d5e0586e59 Fixed
ubuntu/linux(Ubuntu 24.04) < 6.8.0-100.100 6.8.0-100.100 Fixed
ubuntu/linux-raspi(Ubuntu 24.04) < 6.8.0-1047.51 6.8.0-1047.51 Fixed
debian linux = 11.0 No fix listed Versions listed

Affected products

ProductAffected versionsFixed in
azure linux kernel(Azure Linux:3.0) < 6.6.96.1-1 6.6.96.1-1
cbl-mariner kernel(CBL-Mariner:2.0) All versions No fix listed
Microsoft cbl2 kernel 5.15.202.1-1 All versions No fix listed
debian/linux(Debian:12) < 6.1.147-1 6.1.147-1
debian/linux(Debian:12) = 6.1.106-1 No fix listed
debian/linux(Debian:12) = 6.1.106-2 No fix listed
debian/linux(Debian:12) = 6.1.106-3 No fix listed
debian/linux(Debian:12) = 6.1.112-1 No fix listed
debian/linux(Debian:12) = 6.1.115-1 No fix listed
debian/linux(Debian:12) = 6.1.119-1 No fix listed
debian/linux(Debian:12) = 6.1.123-1 No fix listed
debian/linux(Debian:12) = 6.1.124-1 No fix listed
debian/linux(Debian:12) = 6.1.128-1 No fix listed
debian/linux(Debian:12) = 6.1.129-1 No fix listed
debian/linux(Debian:12) = 6.1.133-1 No fix listed
debian/linux(Debian:12) = 6.1.135-1 No fix listed
debian/linux(Debian:12) = 6.1.137-1 No fix listed
debian/linux(Debian:12) = 6.1.139-1 No fix listed
debian/linux(Debian:12) = 6.1.140-1 No fix listed
debian/linux(Debian:12) = 6.1.27-1 No fix listed
debian/linux(Debian:12) = 6.1.37-1 No fix listed
debian/linux(Debian:12) = 6.1.38-1 No fix listed
debian/linux(Debian:12) = 6.1.38-2 No fix listed
debian/linux(Debian:12) = 6.1.38-2~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.38-3 No fix listed
Show 43 more
ProductAffected versionsFixed in
debian/linux(Debian:12) = 6.1.38-4 No fix listed
debian/linux(Debian:12) = 6.1.38-4~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.52-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.64-1 No fix listed
debian/linux(Debian:12) = 6.1.66-1 No fix listed
debian/linux(Debian:12) = 6.1.67-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.76-1 No fix listed
debian/linux(Debian:12) = 6.1.76-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.82-1 No fix listed
debian/linux(Debian:12) = 6.1.85-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.94-1 No fix listed
debian/linux(Debian:12) = 6.1.94-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.98-1 No fix listed
debian/linux(Debian:12) = 6.1.99-1 No fix listed
debian/linux(Debian:13) < 6.12.35-1 6.12.35-1
debian/linux(Debian:14) < 6.12.35-1 6.12.35-1
Linux kernel >= 70d3b8ddcd20d3c859676f56c43c7b2360c70266, < 00a88e9ea1b170d579c56327c38f7e8cf689df87 00a88e9ea1b170d579c56327c38f7e8cf689df87
Linux kernel >= 70d3b8ddcd20d3c859676f56c43c7b2360c70266, < 62b62a2a6dc51ed6e8e334861f04220c9cf8106a 62b62a2a6dc51ed6e8e334861f04220c9cf8106a
Linux kernel >= 70d3b8ddcd20d3c859676f56c43c7b2360c70266, < dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe
Linux kernel >= 70d3b8ddcd20d3c859676f56c43c7b2360c70266, < 31dcbac94bfeabb86bf85b0c36803fdd6536437b 31dcbac94bfeabb86bf85b0c36803fdd6536437b
Linux kernel >= 70d3b8ddcd20d3c859676f56c43c7b2360c70266, < ed16618c380c32c68c06186d0ccbb0d5e0586e59 ed16618c380c32c68c06186d0ccbb0d5e0586e59
Linux kernel = 5.11 No fix listed
Linux kernel < 6.1.142 6.1.142
Linux kernel < 6.6.95 6.6.95
Linux kernel < 6.12.35 6.12.35
Linux kernel < 6.15.4 6.15.4
Linux kernel < 6.16 6.16
ubuntu/linux(Ubuntu:22.04) All versions No fix listed
ubuntu/linux-kvm(Ubuntu:22.04) All versions No fix listed
ubuntu/linux-raspi(Ubuntu:22.04) All versions No fix listed
ubuntu/linux(Ubuntu:24.04) < 6.8.0-100.100 6.8.0-100.100
ubuntu/linux-raspi(Ubuntu:24.04) < 6.8.0-1047.51 6.8.0-1047.51
Linux kernel >= 5.11, < 6.1.142 6.1.142
Linux kernel >= 6.2, < 6.6.95 6.6.95
Linux kernel >= 6.7, < 6.12.35 6.12.35
Linux kernel >= 6.13, < 6.15.4 6.15.4
debian linux = 11.0 No fix listed

References