Skip to contentSkip to conversation

CVE-2026-31597: ocfs2: fix use-after-free in ocfs2_fault() when VM_FAULT_RETRY

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Apr 24

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

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.

The Linux kernel CVE team has assigned CVE-2026-31597 to this issue.

Affected and fixed versions
===========================

	Fixed in 6.12.83 with commit 4cf2768a0291a0cdd0dae801ea0eafa3878a349d
	Fixed in 6.18.24 with commit d45ff441b416d4aa1af72b1db23d959601c04da2
	Fixed in 6.19.14 with commit 76a602fdbb78dd05b2da06f74a988cebc97e82d0
	Fixed in 7.0.1 with commit 925bf22c1b823e231b1baea761fe8a1512e442f2

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2026-31597

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:

	fs/ocfs2/mmap.c
	fs/ocfs2/ocfs2_trace.h

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/4cf2768a0291a0cdd0dae801ea0eafa3878a349d
	https://git.kernel.org/stable/c/d45ff441b416d4aa1af72b1db23d959601c04da2
	https://git.kernel.org/stable/c/76a602fdbb78dd05b2da06f74a988cebc97e82d0
	https://git.kernel.org/stable/c/925bf22c1b823e231b1baea761fe8a1512e442f2
	https://git.kernel.org/stable/c/7de554cabf160e331e4442e2a9ad874ca9875921