5.5medium
mm: Fix a hmm_range_fault() livelock / starvation problem
- Severity
- 5.5medium CVSS:3.1 by NVD
- Exploit likelihood
- 0.12% (higher than 1% of CVEs)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: mm: Fix a hmm_range_fault() livelock / starvation problem If hmm_range_fault() fails a folio_trylock() in do_swap_page, trying to acquire the lock of a device-private folio for migration, to ram, the function will spin until it succeeds grabbing the lock. However, if the process holding the lock is depending on a work item to be completed, which is scheduled on the same CPU as the spinning hmm_range_fault(), that work item might be starved and we end up in a livelock / starvation situation which is never resolved. This can happen, for example if the process holding the device-private folio lock is stuck in migrate_device_unmap()->lru_add_drain_all() sinc lru_add_drain_all() requires a short work-item to be run on all online cpus to complete. A prerequisite for this to happen is: a) Both zone device and system memory folios are considered in migrate_device_unmap(), so that there is a reason to call lru_add_drain_all() for a system memory folio while a folio lock is held on a zone device folio. b) The zone device folio has an initial mapcount > 1 which causes at least one migration PTE entry insertion to be deferred to try_to_migrate(), which can happen after the call to lru_add_drain_all(). c) No or voluntary only preemption. This all seems pretty unlikely to happen, but indeed is hit by the "xe_exec_system_allocator" igt test. Resolve this by waiting for the folio to be unlocked if the folio_trylock() fails in do_swap_page(). Rename migration_entry_wait_on_locked() to softleaf_entry_wait_unlock() and update its documentation to indicate the new use-case. Future code improvements might consider moving the lru_add_drain_all() call in migrate_device_unmap() to be called *after* all pages have migration entries inserted. That would eliminate also b) above. v2: - Instead of a cond_resched() in hmm_range_fault(), eliminate the problem by waiting for the folio to be unlocked in do_swap_page() (Alistair Popple, Andrew Morton) v3: - Add a stub migration_entry_wait_on_locked() for the !CONFIG_MIGRATION case. (Kernel Test Robot) v4: - Rename migrate_entry_wait_on_locked() to softleaf_entry_wait_on_locked() and update docs (Alistair Popple) v5: - Add a WARN_ON_ONCE() for the !CONFIG_MIGRATION version of softleaf_entry_wait_on_locked(). - Modify wording around function names in the commit message (Andrew Morton) (cherry picked from commit a69d1ab971a624c6f112cea61536569d579c3215)
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from 1afaeb8293c9addbf4f9140bdd22635fed763459 before 94b6d0ba4b640ba23bb6c708a59316e74e5ede63, from 1afaeb8293c9addbf4f9140bdd22635fed763459 before 7e6e2fc91d4b9b12ec6e137019532568ebcf2680, from 1afaeb8293c9addbf4f9140bdd22635fed763459 before b570f37a2ce480be26c665345c5514686a8a0274, 6.15 Not affected: before 6.15, from 6.18.19 up to 6.18.*, from 6.19.9 up to 6.19.*, from 7.0 up to * | CVE List |
| linux linux_kernel | from 6.15 before 6.18.19, from 6.19 before 6.19.9, 7.0 | NVD |
Classification
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: mm: Fix a hmm_range_fault() livelock / starvation problem If hmm_range_fault() fails a folio_trylock() in do_swap_page, trying to acquire the lock of a device-private folio for migration, to ram, the function will spin until it succeeds grabbing the lock. However, if the process holding the lock is depending on a work item to be completed, which is scheduled on the same CPU as the spinning hmm_range_fault(), that work item might be starved and we end up in a livelock / starvation situation which is never resolved. This can happen, for example if the process holding the device-private folio lock is stuck in migrate_device_unmap()->lru_add_drain_all() sinc lru_add_drain_all() requires a short work-item to be run on all online cpus to complete. A prerequisite for this to happen is: a) Both zone device and system memory folios are considered in migrate_device_unmap(), so that there is a reason to call lru_add_drain_all() for a system memory folio while a folio lock is held on a zone device folio. b) The zone device folio has an initial mapcount > 1 which causes at least one migration PTE entry insertion to be deferred to try_to_migrate(), which can happen after the call to lru_add_drain_all(). c) No or voluntary only preemption. This all seems pretty unlikely to happen, but indeed is hit by the "xe_exec_system_allocator" igt test. Resolve this by waiting for the folio to be unlocked if the folio_trylock() fails in do_swap_page(). Rename migration_entry_wait_on_locked() to softleaf_entry_wait_unlock() and update its documentation to indicate the new use-case. Future code improvements might consider moving the lru_add_drain_all() call in migrate_device_unmap() to be called *after* all pages have migration entries inserted. That would eliminate also b) above. v2: - Instead of a cond_resched() in hmm_range_fault(), eliminate the problem by waiting for the folio to be unlocked in do_swap_page() (Alistair Popple, Andrew Morton) v3: - Add a stub migration_entry_wait_on_locked() for the !CONFIG_MIGRATION case. (Kernel Test Robot) v4: - Rename migrate_entry_wait_on_locked() to softleaf_entry_wait_on_locked() and update docs (Alistair Popple) v5: - Add a WARN_ON_ONCE() for the !CONFIG_MIGRATION version of softleaf_entry_wait_on_locked(). - Modify wording around function names in the commit message (Andrew Morton) (cherry picked from commit a69d1ab971a624c6f112cea61536569d579c3215)
NVD (es)
En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: mm: Corrige un problema de interbloqueo / inanición de hmm_range_fault() Si hmm_range_fault() falla un folio_trylock() en do_swap_page, intentando adquirir el bloqueo de un folio privado de dispositivo para migración, a la RAM, la función girará hasta que logre adquirir el bloqueo. Sin embargo, si el proceso que mantiene el bloqueo depende de que se complete un elemento de trabajo, el cual está programado en la misma CPU que el hmm_range_fault() en espera activa, ese elemento de trabajo podría sufrir inanición y terminamos en una situación de interbloqueo / inanición que nunca se resuelve. Esto puede ocurrir, por ejemplo, si el proceso que mantiene el bloqueo del folio privado del dispositivo está atascado en migrate_device_unmap() -> lru_add_drain_all() ya que lru_add_drain_all() requiere que se ejecute un elemento de trabajo corto en todas las CPUs en línea para completarse. Un requisito previo para que esto ocurra es: a) Tanto los folios de dispositivo de zona como los de memoria del sistema se consideran en migrate_device_unmap(), de modo que hay una razón para llamar a lru_add_drain_all() para un folio de memoria del sistema mientras se mantiene un bloqueo de folio en un folio de dispositivo de zona. b) El folio de dispositivo de zona tiene un mapcount inicial mayor que 1 lo que provoca que al menos una inserción de entrada PTE de migración se posponga a try_to_migrate(), lo cual puede ocurrir después de la llamada a lru_add_drain_all(). c) Sin o solo con expropiación voluntaria. Todo esto parece bastante improbable que ocurra, pero de hecho es afectado por la prueba igt ’xe_exec_system_allocator’. Resuelve esto esperando a que el folio se desbloquee si el folio_trylock() falla en do_swap_page(). Renombra migration_entry_wait_on_locked() a softleaf_entry_wait_unlock() y actualiza su documentación para indicar el nuevo caso de uso. Futuras mejoras de código podrían considerar mover la llamada a lru_add_drain_all() en migrate_device_unmap() para que se llame después de que todas las páginas tengan entradas de migración insertadas. Eso eliminaría también b) lo anterior. v2: - En lugar de un cond_resched() en hmm_range_fault(), elimina el problema esperando a que el folio se desbloquee en do_swap_page() (Alistair Popple, Andrew Morton) v3: - Añade un stub migration_entry_wait_on_locked() para el caso !CONFIG_MIGRATION. (Kernel Test Robot) v4: - Renombra migrate_entry_wait_on_locked() a softleaf_entry_wait_on_locked() y actualiza la documentación (Alistair Popple) v5: - Añade un WARN_ON_ONCE() para la versión !CONFIG_MIGRATION de softleaf_entry_wait_on_locked(). - Modifica la redacción en torno a los nombres de las funciones en el mensaje de commit (Andrew Morton) (seleccionado de commit a69d1ab971a624c6f112cea61536569d579c3215)
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-43404 changed 2026-05-11 | CVE Terms of Use |
| NVD | CVE-2026-43404 changed 2026-11-11 | Public domain |