CVE-2025-38334 (GCVE-0-2025-38334)
Vulnerability from cvelistv5
Published
2025-07-10 08:15
Modified
2025-07-28 04:19
Severity ?
VLAI Severity ?
EPSS score ?
Summary
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.
References
Impacted products
{ "containers": { "cna": { "affected": [ { "defaultStatus": "unaffected", "product": "Linux", "programFiles": [ "arch/x86/kernel/cpu/sgx/main.c" ], "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git", "vendor": "Linux", "versions": [ { "lessThan": "00a88e9ea1b170d579c56327c38f7e8cf689df87", "status": "affected", "version": "70d3b8ddcd20d3c859676f56c43c7b2360c70266", "versionType": "git" }, { "lessThan": "62b62a2a6dc51ed6e8e334861f04220c9cf8106a", "status": "affected", "version": "70d3b8ddcd20d3c859676f56c43c7b2360c70266", "versionType": "git" }, { "lessThan": "dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe", "status": "affected", "version": "70d3b8ddcd20d3c859676f56c43c7b2360c70266", "versionType": "git" }, { "lessThan": "31dcbac94bfeabb86bf85b0c36803fdd6536437b", "status": "affected", "version": "70d3b8ddcd20d3c859676f56c43c7b2360c70266", "versionType": "git" }, { "lessThan": "ed16618c380c32c68c06186d0ccbb0d5e0586e59", "status": "affected", "version": "70d3b8ddcd20d3c859676f56c43c7b2360c70266", "versionType": "git" } ] }, { "defaultStatus": "affected", "product": "Linux", "programFiles": [ "arch/x86/kernel/cpu/sgx/main.c" ], "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git", "vendor": "Linux", "versions": [ { "status": "affected", "version": "5.11" }, { "lessThan": "5.11", "status": "unaffected", "version": "0", "versionType": "semver" }, { "lessThanOrEqual": "6.1.*", "status": "unaffected", "version": "6.1.142", "versionType": "semver" }, { "lessThanOrEqual": "6.6.*", "status": "unaffected", "version": "6.6.95", "versionType": "semver" }, { "lessThanOrEqual": "6.12.*", "status": "unaffected", "version": "6.12.35", "versionType": "semver" }, { "lessThanOrEqual": "6.15.*", "status": "unaffected", "version": "6.15.4", "versionType": "semver" }, { "lessThanOrEqual": "*", "status": "unaffected", "version": "6.16", "versionType": "original_commit_for_fix" } ] } ], "cpeApplicability": [ { "nodes": [ { "cpeMatch": [ { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.1.142", "versionStartIncluding": "5.11", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.6.95", "versionStartIncluding": "5.11", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.12.35", "versionStartIncluding": "5.11", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.15.4", "versionStartIncluding": "5.11", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.16", "versionStartIncluding": "5.11", "vulnerable": true } ], "negate": false, "operator": "OR" } ] } ], "descriptions": [ { "lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nx86/sgx: Prevent attempts to reclaim poisoned pages\n\nTL;DR: SGX page reclaim touches the page to copy its contents to\nsecondary storage. SGX instructions do not gracefully handle machine\nchecks. Despite this, the existing SGX code will try to reclaim pages\nthat it _knows_ are poisoned. Avoid even trying to reclaim poisoned pages.\n\nThe longer story:\n\nPages used by an enclave only get epc_page-\u003epoison set in\narch_memory_failure() but they currently stay on sgx_active_page_list until\nsgx_encl_release(), with the SGX_EPC_PAGE_RECLAIMER_TRACKED flag untouched.\n\nepc_page-\u003epoison is not checked in the reclaimer logic meaning that, if other\nconditions are met, an attempt will be made to reclaim an EPC page that was\npoisoned. This is bad because 1. we don\u0027t want that page to end up added\nto another enclave and 2. it is likely to cause one core to shut down\nand the kernel to panic.\n\nSpecifically, reclaiming uses microcode operations including \"EWB\" which\naccesses the EPC page contents to encrypt and write them out to non-SGX\nmemory. Those operations cannot handle MCEs in their accesses other than\nby putting the executing core into a special shutdown state (affecting\nboth threads with HT.) The kernel will subsequently panic on the\nremaining cores seeing the core didn\u0027t enter MCE handler(s) in time.\n\nCall sgx_unmark_page_reclaimable() to remove the affected EPC page from\nsgx_active_page_list on memory error to stop it being considered for\nreclaiming.\n\nTesting epc_page-\u003epoison in sgx_reclaim_pages() would also work but I assume\nit\u0027s better to add code in the less likely paths.\n\nThe affected EPC page is not added to \u0026node-\u003esgx_poison_page_list until\nlater in sgx_encl_release()-\u003esgx_free_epc_page() when it is EREMOVEd.\nMembership on other lists doesn\u0027t change to avoid changing any of the\nlists\u0027 semantics except for sgx_active_page_list. There\u0027s a \"TBD\" comment\nin arch_memory_failure() about pre-emptive actions, the goal here is not\nto address everything that it may imply.\n\nThis also doesn\u0027t completely close the time window when a memory error\nnotification will be fatal (for a not previously poisoned EPC page) --\nthe MCE can happen after sgx_reclaim_pages() has selected its candidates\nor even *inside* a microcode operation (actually easy to trigger due to\nthe amount of time spent in them.)\n\nThe spinlock in sgx_unmark_page_reclaimable() is safe because\nmemory_failure() runs in process context and no spinlocks are held,\nexplicitly noted in a mm/memory-failure.c comment." } ], "providerMetadata": { "dateUpdated": "2025-07-28T04:19:08.877Z", "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "shortName": "Linux" }, "references": [ { "url": "https://git.kernel.org/stable/c/00a88e9ea1b170d579c56327c38f7e8cf689df87" }, { "url": "https://git.kernel.org/stable/c/62b62a2a6dc51ed6e8e334861f04220c9cf8106a" }, { "url": "https://git.kernel.org/stable/c/dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe" }, { "url": "https://git.kernel.org/stable/c/31dcbac94bfeabb86bf85b0c36803fdd6536437b" }, { "url": "https://git.kernel.org/stable/c/ed16618c380c32c68c06186d0ccbb0d5e0586e59" } ], "title": "x86/sgx: Prevent attempts to reclaim poisoned pages", "x_generator": { "engine": "bippy-1.2.0" } } }, "cveMetadata": { "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "assignerShortName": "Linux", "cveId": "CVE-2025-38334", "datePublished": "2025-07-10T08:15:06.380Z", "dateReserved": "2025-04-16T04:51:24.005Z", "dateUpdated": "2025-07-28T04:19:08.877Z", "state": "PUBLISHED" }, "dataType": "CVE_RECORD", "dataVersion": "5.1", "vulnerability-lookup:meta": { "nvd": "{\"cve\":{\"id\":\"CVE-2025-38334\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2025-07-10T09:15:27.960\",\"lastModified\":\"2025-07-10T13:17:30.017\",\"vulnStatus\":\"Awaiting Analysis\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nx86/sgx: Prevent attempts to reclaim poisoned pages\\n\\nTL;DR: SGX page reclaim touches the page to copy its contents to\\nsecondary storage. SGX instructions do not gracefully handle machine\\nchecks. Despite this, the existing SGX code will try to reclaim pages\\nthat it _knows_ are poisoned. Avoid even trying to reclaim poisoned pages.\\n\\nThe longer story:\\n\\nPages used by an enclave only get epc_page-\u003epoison set in\\narch_memory_failure() but they currently stay on sgx_active_page_list until\\nsgx_encl_release(), with the SGX_EPC_PAGE_RECLAIMER_TRACKED flag untouched.\\n\\nepc_page-\u003epoison is not checked in the reclaimer logic meaning that, if other\\nconditions are met, an attempt will be made to reclaim an EPC page that was\\npoisoned. This is bad because 1. we don\u0027t want that page to end up added\\nto another enclave and 2. it is likely to cause one core to shut down\\nand the kernel to panic.\\n\\nSpecifically, reclaiming uses microcode operations including \\\"EWB\\\" which\\naccesses the EPC page contents to encrypt and write them out to non-SGX\\nmemory. Those operations cannot handle MCEs in their accesses other than\\nby putting the executing core into a special shutdown state (affecting\\nboth threads with HT.) The kernel will subsequently panic on the\\nremaining cores seeing the core didn\u0027t enter MCE handler(s) in time.\\n\\nCall sgx_unmark_page_reclaimable() to remove the affected EPC page from\\nsgx_active_page_list on memory error to stop it being considered for\\nreclaiming.\\n\\nTesting epc_page-\u003epoison in sgx_reclaim_pages() would also work but I assume\\nit\u0027s better to add code in the less likely paths.\\n\\nThe affected EPC page is not added to \u0026node-\u003esgx_poison_page_list until\\nlater in sgx_encl_release()-\u003esgx_free_epc_page() when it is EREMOVEd.\\nMembership on other lists doesn\u0027t change to avoid changing any of the\\nlists\u0027 semantics except for sgx_active_page_list. There\u0027s a \\\"TBD\\\" comment\\nin arch_memory_failure() about pre-emptive actions, the goal here is not\\nto address everything that it may imply.\\n\\nThis also doesn\u0027t completely close the time window when a memory error\\nnotification will be fatal (for a not previously poisoned EPC page) --\\nthe MCE can happen after sgx_reclaim_pages() has selected its candidates\\nor even *inside* a microcode operation (actually easy to trigger due to\\nthe amount of time spent in them.)\\n\\nThe spinlock in sgx_unmark_page_reclaimable() is safe because\\nmemory_failure() runs in process context and no spinlocks are held,\\nexplicitly noted in a mm/memory-failure.c comment.\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: x86/sgx: Evitar intentos de recuperar p\u00e1ginas envenenadas TL;DR: La recuperaci\u00f3n de p\u00e1gina SGX toca la p\u00e1gina para copiar su contenido al almacenamiento secundario. Las instrucciones SGX no manejan correctamente las comprobaciones de la m\u00e1quina. A pesar de esto, el c\u00f3digo SGX existente intentar\u00e1 recuperar las p\u00e1ginas que _sabe_ que est\u00e1n envenenadas. Evite incluso intentar recuperar p\u00e1ginas envenenadas. En resumen: Las p\u00e1ginas utilizadas por un enclave solo obtienen epc_page-\u0026gt;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-\u0026gt;poison no se comprueba en la l\u00f3gica del recuperador, lo que significa que, si se cumplen otras condiciones, se intentar\u00e1 recuperar una p\u00e1gina EPC que fue envenenada. Esto es perjudicial porque 1. no queremos que esa p\u00e1gina se a\u00f1ada a otro enclave y 2. es probable que provoque el apagado de un n\u00facleo y el p\u00e1nico del kernel. En concreto, la recuperaci\u00f3n utiliza operaciones de microc\u00f3digo, como \\\"EWB\\\", que accede al contenido de la p\u00e1gina EPC para cifrarlo y escribirlo en memoria no SGX. Estas operaciones no pueden gestionar MCE en sus accesos, salvo que pongan el n\u00facleo en ejecuci\u00f3n en un estado de apagado especial (lo que afecta a ambos hilos con HT). El kernel posteriormente entrar\u00e1 en p\u00e1nico en los n\u00facleos restantes, al ver que el n\u00facleo no accedi\u00f3 a los controladores de MCE a tiempo. Llama a sgx_unmark_page_reclaimable() para eliminar la p\u00e1gina EPC afectada de sgx_active_page_list en caso de error de memoria y as\u00ed evitar que se considere su recuperaci\u00f3n. Probar epc_page-\u0026gt;poison en sgx_reclaim_pages() tambi\u00e9n funcionar\u00eda, pero supongo que es mejor a\u00f1adir c\u00f3digo en las rutas menos probables. La p\u00e1gina EPC afectada no se a\u00f1ade a \u0026amp;node-\u0026gt;sgx_poison_page_list hasta m\u00e1s adelante en sgx_encl_release()-\u0026gt;sgx_free_epc_page(), cuando se elimina. La membres\u00eda en otras listas no cambia para evitar modificar la sem\u00e1ntica 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\u00f3n de error de memoria ser\u00e1 fatal (para una p\u00e1gina EPC que no haya sido envenenada previamente) - el MCE puede ocurrir despu\u00e9s de que sgx_reclaim_pages() haya seleccionado sus candidatos o incluso *dentro* de una operaci\u00f3n de microc\u00f3digo (en realidad, f\u00e1cil 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\u00f1ala expl\u00edcitamente en un comentario mm/memory-failure.c.\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/00a88e9ea1b170d579c56327c38f7e8cf689df87\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/31dcbac94bfeabb86bf85b0c36803fdd6536437b\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/62b62a2a6dc51ed6e8e334861f04220c9cf8106a\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/dc5de5bd6deabd327ced2b2b1d0b4f14cd146afe\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/ed16618c380c32c68c06186d0ccbb0d5e0586e59\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}" } }
Loading…
Loading…
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.
Loading…
Loading…