9.8critical
mm/filemap: __filemap_add_folio() restore index before retrying
- Severity
- 9.8critical CVSS:3.1 by Linux
- Exploit likelihood
- 0.44% (higher than 40% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: mm/filemap: __filemap_add_folio() restore index before retrying In __filemap_add_folio()'s split-a-conflict loop, xas_set_order() is applied repeatedly: each application modifies xas.xa_index, rounding it down according to the split_order attempted at that stage: and if all goes as intended, it eventually (or immediately) converges on an xas_try_split() to the required folio_order, with xas.xa_index now the same as index: then xas_store() puts the new folio into the xarray there. But if a new node was needed, and GFP_NOWAIT allocation did not get one, the lock is dropped, xas_nomem() used to allocate, and sequence retried. If (that part of) the xarray is unchanged when the lock is reacquired, no problem. But what if the conflict was meanwhile resolved by another thread (perhaps even doing the same thing, inserting a folio at that same index)? Isn't there a danger of now putting our folio into the xarray at an intermediate rounded-down index? With !folio_contains() bug to follow, when CONFIG_DEBUG_VM=y is checking for that. Fix this with an xas_set_order() to restore the original xas.xa_index at the bottom of the loop, so the retry does a full re-evaluation after reacquiring the lock, and cannot reach xas_store() with the wrong index. Production was suffering from rare SIGILLs and SIGSEGVs, executable text found a page away from where it belonged, !folio_contains() bug hit when debug enabled: symptoms not seen since this patch went in.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from 200a89c159a7a416115e6e309183c82183bf98aa before 4917e3ebcab50f0265e8ca01c8567de4c4a47511, from 200a89c159a7a416115e6e309183c82183bf98aa before 267ecd2eb7759c26f1a026eb0a5b231071534c9c, from 200a89c159a7a416115e6e309183c82183bf98aa before 86da3f7e1e609e1e8bfbab198af68467c5a015a5, 6.15 Not affected: before 6.15, from 6.18.45 up to 6.18.*, from 7.1.9 up to 7.1.*, from 7.2 up to * | CVE List |
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: mm/filemap: __filemap_add_folio() restore index before retrying In __filemap_add_folio()'s split-a-conflict loop, xas_set_order() is applied repeatedly: each application modifies xas.xa_index, rounding it down according to the split_order attempted at that stage: and if all goes as intended, it eventually (or immediately) converges on an xas_try_split() to the required folio_order, with xas.xa_index now the same as index: then xas_store() puts the new folio into the xarray there. But if a new node was needed, and GFP_NOWAIT allocation did not get one, the lock is dropped, xas_nomem() used to allocate, and sequence retried. If (that part of) the xarray is unchanged when the lock is reacquired, no problem. But what if the conflict was meanwhile resolved by another thread (perhaps even doing the same thing, inserting a folio at that same index)? Isn't there a danger of now putting our folio into the xarray at an intermediate rounded-down index? With !folio_contains() bug to follow, when CONFIG_DEBUG_VM=y is checking for that. Fix this with an xas_set_order() to restore the original xas.xa_index at the bottom of the loop, so the retry does a full re-evaluation after reacquiring the lock, and cannot reach xas_store() with the wrong index. Production was suffering from rare SIGILLs and SIGSEGVs, executable text found a page away from where it belonged, !folio_contains() bug hit when debug enabled: symptoms not seen since this patch went in.
NVD (es)
En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: mm/filemap: __filemap_add_folio() restaurar índice antes de reintentar En el bucle de división de conflicto de __filemap_add_folio(), xas_set_order() se aplica repetidamente: cada aplicación modifica xas.xa_index, redondeándolo hacia abajo según el split_order intentado en esa etapa; y si todo va según lo previsto, finalmente (o inmediatamente) converge en un xas_try_split() al folio_order requerido, con xas.xa_index ahora igual que index; entonces xas_store() coloca el nuevo folio en el xarray allí. Pero si se necesitaba un nuevo nodo, y la asignación GFP_NOWAIT no obtuvo uno, el bloqueo se libera, xas_nomem() se usa para asignar, y la secuencia se reintenta. Si (esa parte de) el xarray no cambia cuando se vuelve a adquirir el bloqueo, no hay problema. Pero ¿qué pasa si el conflicto fue resuelto mientras tanto por otro hilo (quizás incluso haciendo lo mismo, insertando un folio en ese mismo índice)? ¿No hay peligro de ahora poner nuestro folio en el xarray en un índice intermedio redondeado hacia abajo? Con el error !folio_contains() a continuación, cuando CONFIG_DEBUG_VM=y está comprobando eso. Solucione esto con un xas_set_order() para restaurar el xas.xa_index original al final del bucle, para que el reintento realice una reevaluación completa después de volver a adquirir el bloqueo, y no pueda alcanzar xas_store() con el índice incorrecto. La producción estaba sufriendo de SIGILLs y SIGSEGVs raros, texto ejecutable encontrado a una página de donde debía estar, error !folio_contains() activado cuando la depuración estaba habilitada: síntomas no vistos desde que este parche entró.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-74591 changed 2026-08-25 | CVE Terms of Use |
| NVD | CVE-2026-74591 changed 2026-10-14 | Public domain |