7.8high
ocfs2: fix use-after-free in ocfs2_fault() when VM_FAULT_RETRY
- Severity
- 7.8high CVSS:3.1 by Linux
- Exploit likelihood
- 0.13% (higher than 3% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: ocfs2: fix use-after-free in ocfs2_fault() when VM_FAULT_RETRY filemap_fault() may drop the mmap_lock before returning VM_FAULT_RETRY, as documented in mm/filemap.c: "If our return value has VM_FAULT_RETRY set, it's because the mmap_lock may be dropped before doing I/O or by lock_folio_maybe_drop_mmap()." When this happens, a concurrent munmap() can call remove_vma() and free the vm_area_struct via RCU. The saved 'vma' pointer in ocfs2_fault() then becomes a dangling pointer, and the subsequent trace_ocfs2_fault() call dereferences it -- a use-after-free. Fix this by saving ip_blkno as a plain integer before calling filemap_fault(), and removing vma from the trace event. Since ip_blkno is copied by value before the lock can be dropped, it remains valid regardless of what happens to the vma or inode afterward.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from 614a9e849ca6ea24843795251cb30af525d5336b before 36539c4d536f851a3b346a6ebb27b51bc3d77a94, from 614a9e849ca6ea24843795251cb30af525d5336b before 35c2c05261d6f6d84aaa1355afa201d507943e76, from 614a9e849ca6ea24843795251cb30af525d5336b before 3f5e74b5db9353b01ed50f4de84e75b755f8fbc2, from 614a9e849ca6ea24843795251cb30af525d5336b before 6f072daefcab1d84ce37c073645615f63be91006, from 614a9e849ca6ea24843795251cb30af525d5336b before 4cf2768a0291a0cdd0dae801ea0eafa3878a349d, from 614a9e849ca6ea24843795251cb30af525d5336b before d45ff441b416d4aa1af72b1db23d959601c04da2, from 614a9e849ca6ea24843795251cb30af525d5336b before 76a602fdbb78dd05b2da06f74a988cebc97e82d0, from 614a9e849ca6ea24843795251cb30af525d5336b before 925bf22c1b823e231b1baea761fe8a1512e442f2 and 2 more Not affected: before 2.6.39, from 5.10.258 up to 5.10.*, from 5.15.209 up to 5.15.*, from 6.1.175 up to 6.1.*, from 6.6.136 up to 6.6.*, from 6.12.83 up to 6.12.* | CVE List |
| linux linux_kernel | from 2.6.39 before 6.6.136, from 6.7 before 6.12.83, from 6.13 before 6.18.24, from 6.19 before 6.19.14, from 7.0 before 7.0.1 | NVD |
Classification
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: ocfs2: fix use-after-free in ocfs2_fault() when VM_FAULT_RETRY filemap_fault() may drop the mmap_lock before returning VM_FAULT_RETRY, as documented in mm/filemap.c: "If our return value has VM_FAULT_RETRY set, it's because the mmap_lock may be dropped before doing I/O or by lock_folio_maybe_drop_mmap()." When this happens, a concurrent munmap() can call remove_vma() and free the vm_area_struct via RCU. The saved 'vma' pointer in ocfs2_fault() then becomes a dangling pointer, and the subsequent trace_ocfs2_fault() call dereferences it -- a use-after-free. Fix this by saving ip_blkno as a plain integer before calling filemap_fault(), and removing vma from the trace event. Since ip_blkno is copied by value before the lock can be dropped, it remains valid regardless of what happens to the vma or inode afterward.
NVD (es)
En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: ocfs2: corrección de uso después de liberación en ocfs2_fault() cuando VM_FAULT_RETRY filemap_fault() puede liberar el mmap_lock antes de devolver VM_FAULT_RETRY, como se documenta en mm/filemap.c: ’Si nuestro valor de retorno tiene VM_FAULT_RETRY establecido, es porque el mmap_lock puede ser liberado antes de realizar E/S o por lock_folio_maybe_drop_mmap().’ Cuando esto sucede, un munmap() concurrente puede llamar a remove_vma() y liberar el vm_area_struct a través de RCU. El puntero ’vma’ guardado en ocfs2_fault() entonces se convierte en un puntero colgante, y la subsiguiente llamada a trace_ocfs2_fault() lo desreferencia - - un uso después de liberación. Solucione esto al guardar ip_blkno como un entero simple antes de llamar a filemap_fault(), y eliminando vma del evento de traza. Dado que ip_blkno se copia por valor antes de que el bloqueo pueda ser liberado, permanece válido independientemente de lo que suceda con el vma o el inodo después.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-31597 changed 2026-08-05 | CVE Terms of Use |
| NVD | CVE-2026-31597 changed 2026-11-11 | Public domain |