KernelScan.io

HIGH

ocfs2 Fault Handler UAF

CVE-2026-31597

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.8HIGH

01

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.

02

Engine v0.2.0

Risk summary

This vulnerability allows local attackers to cause use-after-free conditions in the OCFS2 filesystem's memory mapping code. When page faults occur on memory-mapped OCFS2 files and race with munmap operations, the kernel may dereference freed memory, potentially leading to system crashes or privilege escalation. The issue affects systems using OCFS2 filesystems where users can perform memory mapping operations.

Affectedfs/ocfs2/mmap.c

Vulnerability analysis

Summary: Use-after-free vulnerability in ocfs2_fault() when filemap_fault() returns VM_FAULT_RETRY

Root Cause: The ocfs2_fault() function saves a pointer to the vm_area_struct (vma) at the beginning, then calls filemap_fault(). When filemap_fault() returns VM_FAULT_RETRY, it may have dropped the mmap_lock, allowing a concurrent munmap() to free the vma via RCU. The saved vma pointer becomes dangling, and the subsequent trace_ocfs2_fault() call dereferences it, causing a use-after-free.

Attack Surface: Local attack surface requiring the ability to trigger memory-mapped file operations on OCFS2 filesystems. The vulnerability is triggered through normal file system operations (mmap/munmap) that can race with page fault handling.

Fix Mechanism: The fix saves the ip_blkno value as a plain integer before calling filemap_fault(), and removes the vma parameter from the trace event. Since ip_blkno is copied by value before any locks can be dropped, it remains valid regardless of what happens to the vma or inode afterward.

03

BranchFixed inPatch commit
5.105.10.25836539c4d536f
5.155.15.20935c2c05261d6
6.16.1.1753f5e74b5db93
6.126.12.834cf2768a0291
6.186.18.24d45ff441b416
6.196.19.1476a602fdbb78
6.66.6.1366f072daefcab
7.07.0.1925bf22c1b82
mainline7.1-rc17de554cabf16