CVE-2025-38334

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.
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*

Configuration 2 (hide)

cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*

History

16 Dec 2025, 17:55

Type Values Removed Values Added
References () https://git.kernel.org/stable/c/00a88e9ea1b170d579c56327c38f7e8cf689df87 - () https://git.kernel.org/stable/c/00a88e9ea1b170d579c56327c38f7e8cf689df87 - Patch
References () https://git.kernel.org/stable/c/31dcbac94bfeabb86bf85b0c36803fdd6536437b - () https://git.kernel.org/stable/c/31dcbac94bfeabb86bf85b0c36803fdd6536437b - Patch
References () https://git.kernel.org/stable/c/62b62a2a6dc51ed6e8e334861f04220c9cf8106a - () https://git.kernel.org/stable/c/62b62a2a6dc51ed6e8e334861f04220c9cf8106a - Patch
References () https://git.kernel.org/stable/c/dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe - () https://git.kernel.org/stable/c/dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe - Patch
References () https://git.kernel.org/stable/c/ed16618c380c32c68c06186d0ccbb0d5e0586e59 - () https://git.kernel.org/stable/c/ed16618c380c32c68c06186d0ccbb0d5e0586e59 - Patch
References () https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html - () https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html - Third Party Advisory
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 5.5
CPE cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
CWE CWE-754
First Time Linux
Debian
Debian debian Linux
Linux linux Kernel

03 Nov 2025, 18:16

Type Values Removed Values Added
References
  • () https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html -
Summary
  • (es) En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: x86/sgx: Evitar intentos de recuperar páginas envenenadas TL;DR: La recuperación de página SGX toca la página para copiar su contenido al almacenamiento secundario. Las instrucciones SGX no manejan correctamente las comprobaciones de la máquina. A pesar de esto, el código SGX existente intentará recuperar las páginas que _sabe_ que están envenenadas. Evite incluso intentar recuperar páginas envenenadas. En resumen: Las páginas utilizadas por un enclave solo obtienen epc_page->poison establecida en arch_memory_failure(), pero actualmente permanecen en sgx_active_page_list hasta sgx_encl_release(), con el indicador SGX_EPC_PAGE_RECLAIMER_TRACKED intacto. epc_page->poison no se comprueba en la lógica del recuperador, lo que significa que, si se cumplen otras condiciones, se intentará recuperar una página EPC que fue envenenada. Esto es perjudicial porque 1. no queremos que esa página se añada a otro enclave y 2. es probable que provoque el apagado de un núcleo y el pánico del kernel. En concreto, la recuperación utiliza operaciones de microcódigo, como "EWB", que accede al contenido de la página EPC para cifrarlo y escribirlo en memoria no SGX. Estas operaciones no pueden gestionar MCE en sus accesos, salvo que pongan el núcleo en ejecución en un estado de apagado especial (lo que afecta a ambos hilos con HT). El kernel posteriormente entrará en pánico en los núcleos restantes, al ver que el núcleo no accedió a los controladores de MCE a tiempo. Llama a sgx_unmark_page_reclaimable() para eliminar la página EPC afectada de sgx_active_page_list en caso de error de memoria y así evitar que se considere su recuperación. Probar epc_page->poison en sgx_reclaim_pages() también funcionaría, pero supongo que es mejor añadir código en las rutas menos probables. La página EPC afectada no se añade a &node->sgx_poison_page_list hasta más adelante en sgx_encl_release()->sgx_free_epc_page(), cuando se elimina. La membresía en otras listas no cambia para evitar modificar la semántica de las listas, excepto la de sgx_active_page_list. Hay un comentario "TBD" en arch_memory_failure() sobre acciones preventivas; el objetivo no es abordar todo lo que pueda implicar. Esto tampoco cierra completamente la ventana de tiempo cuando una notificación de error de memoria será fatal (para una página EPC que no haya sido envenenada previamente) - el MCE puede ocurrir después de que sgx_reclaim_pages() haya seleccionado sus candidatos o incluso *dentro* de una operación de microcódigo (en realidad, fácil de activar debido a la cantidad de tiempo empleado en ellas). El bloqueo de giro en sgx_unmark_page_reclaimable() es seguro porque memory_failure() se ejecuta en el contexto del proceso y no se mantienen bloqueos de giro, lo que se señala explícitamente en un comentario mm/memory-failure.c.

10 Jul 2025, 09:15

Type Values Removed Values Added
New CVE

Information

Published : 2025-07-10 09:15

Updated : 2025-12-16 17:55


NVD link : CVE-2025-38334

Mitre link : CVE-2025-38334

CVE.ORG link : CVE-2025-38334


JSON object : View

Products Affected

debian

  • debian_linux

linux

  • linux_kernel
CWE
CWE-754

Improper Check for Unusual or Exceptional Conditions