Re: [syzbot] [crypto?] KASAN: slab-use-after-free Read in handle_mm_fault

From: Hillf Danton
Date: Tue Jul 16 2024 - 07:56:09 EST


On Tue, 16 Jul 2024 01:29:17 -0700
> syzbot found the following issue on:
>
> HEAD commit: 3fe121b62282 Add linux-next specific files for 20240712
> git tree: linux-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13ce3259980000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 3fe121b62282

--- x/mm/memory.c
+++ y/mm/memory.c
@@ -5808,6 +5808,7 @@ vm_fault_t handle_mm_fault(struct vm_are
/* If the fault handler drops the mmap_lock, vma may be freed */
struct mm_struct *mm = vma->vm_mm;
vm_fault_t ret;
+ bool droppable;

__set_current_state(TASK_RUNNING);

@@ -5831,6 +5832,7 @@ vm_fault_t handle_mm_fault(struct vm_are

lru_gen_enter_fault(vma);

+ droppable = !!(vma->vm_flags & VM_DROPPABLE);
if (unlikely(is_vm_hugetlb_page(vma)))
ret = hugetlb_fault(vma->vm_mm, vma, address, flags);
else
@@ -5839,7 +5841,7 @@ vm_fault_t handle_mm_fault(struct vm_are
lru_gen_exit_fault();

/* If the mapping is droppable, then errors due to OOM aren't fatal. */
- if (vma->vm_flags & VM_DROPPABLE)
+ if (droppable)
ret &= ~VM_FAULT_OOM;

if (flags & FAULT_FLAG_USER) {
--