milos-linux/fs/ocfs2
Tejas Bharambe 7de554cabf 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.

Link: https://lkml.kernel.org/r/20260410083816.34951-1-tejas.bharambe@outlook.com
Fixes: 614a9e849c ("ocfs2: Remove FILE_IO from masklog.")
Signed-off-by: Tejas Bharambe <tejas.bharambe@outlook.com>
Reported-by: syzbot+a49010a0e8fcdeea075f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a49010a0e8fcdeea075f
Suggested-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-04-15 02:15:02 -07:00
..
cluster ocfs2/heartbeat: fix slot mapping rollback leaks on error paths 2026-04-15 02:15:01 -07:00
dlm ocfs2/dlm: fix off-by-one in dlm_match_regions() region comparison 2026-03-27 21:19:49 -07:00
dlmfs treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
acl.c fs: inline current_umask() and move it to fs_struct.h 2025-11-05 22:51:23 +01:00
acl.h
alloc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
alloc.h
aops.c ocfs2: fix possible deadlock between unlink and dio_end_io_write 2026-03-27 21:19:43 -07:00
aops.h
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: convert remaining read-only checks to ocfs2_emergency_state 2025-12-10 16:07:43 -08:00
buffer_head_io.h
dcache.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
dcache.h
dir.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
dir.h
dlmglue.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dlmglue.h
export.c ocfs2: detect released suballocator BG for fh_to_[dentry|parent] 2026-01-20 19:44:16 -08:00
export.h
extent_map.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
extent_map.h
file.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
file.h
filecheck.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
filecheck.h
heartbeat.c
heartbeat.h
inode.c ocfs2: validate inline data i_size during inode read 2026-01-20 19:44:17 -08:00
inode.h ocfs2: retire ocfs2_drop_inode() and I_WILL_FREE usage 2025-10-20 20:22:25 +02:00
ioctl.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ioctl.h
journal.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
journal.h
Kconfig
localalloc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
localalloc.h
locks.c
locks.h
Makefile
mmap.c ocfs2: fix use-after-free in ocfs2_fault() when VM_FAULT_RETRY 2026-04-15 02:15:02 -07:00
mmap.h
move_extents.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
move_extents.h
namei.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
namei.h
ocfs1_fs_compat.h
ocfs2.h ocfs2: add ocfs2_emergency_state helper and apply to setattr 2025-12-10 16:07:43 -08:00
ocfs2_fs.h ocfs2: annotate more flexible array members with __counted_by_le() 2026-01-20 19:44:18 -08:00
ocfs2_ioctl.h
ocfs2_lockid.h
ocfs2_lockingver.h
ocfs2_trace.h ocfs2: fix use-after-free in ocfs2_fault() when VM_FAULT_RETRY 2026-04-15 02:15:02 -07:00
quota.h
quota_global.c ocfs2: fix deadlock when creating quota file 2026-03-27 21:19:38 -07:00
quota_local.c ocfs2: fix deadlock when creating quota file 2026-03-27 21:19:38 -07:00
refcounttree.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
refcounttree.h
reservations.c
reservations.h
resize.c ocfs2: handle invalid dinode in ocfs2_group_extend 2026-04-15 02:15:02 -07:00
resize.h
slot_map.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
slot_map.h
stack_o2cb.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
stack_user.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
stackglue.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
stackglue.h
suballoc.c ocfs2: validate bg_list extent bounds in discontig groups 2026-04-15 02:15:02 -07:00
suballoc.h
super.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
super.h
symlink.c
symlink.h
sysfile.c
sysfile.h
uptodate.c
uptodate.h
xattr.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
xattr.h