syzbot


KFENCE: use-after-free in aio_poll_cancel

Status: auto-closed as invalid on 2021/11/04 00:42
Reported-by: syzbot+9d119fe604dc601c6e20@syzkaller.appspotmail.com
First crash: 451d, last: 451d

Sample crash report:
==================================================================
BUG: KFENCE: use-after-free read in __lock_acquire+0xd87/0x54a0 kernel/locking/lockdep.c:4885

Use-after-free read at 0xffff88823bc7a7a0 (in kfence-#60):
 __lock_acquire+0xd87/0x54a0 kernel/locking/lockdep.c:4885
 lock_acquire kernel/locking/lockdep.c:5625 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:368 [inline]
 aio_poll_cancel+0x3e/0x290 fs/aio.c:1661
 free_ioctx_users+0xa4/0x230 fs/aio.c:622
 percpu_ref_put_many.constprop.0+0x22b/0x260 include/linux/percpu-refcount.h:322
 rcu_do_batch kernel/rcu/tree.c:2506 [inline]
 rcu_core+0x7ab/0x1470 kernel/rcu/tree.c:2741
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:636
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:648
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
 lock_acquire+0x1ef/0x510 kernel/locking/lockdep.c:5593
 rcu_lock_acquire include/linux/rcupdate.h:267 [inline]
 rcu_read_lock include/linux/rcupdate.h:687 [inline]
 folio_memcg_lock+0x3a/0x3e0 mm/memcontrol.c:1984
 page_remove_rmap+0x25/0x1480 mm/rmap.c:1348
 zap_pte_range mm/memory.c:1362 [inline]
 zap_pmd_range mm/memory.c:1481 [inline]
 zap_pud_range mm/memory.c:1510 [inline]
 zap_p4d_range mm/memory.c:1531 [inline]
 unmap_page_range+0xed5/0x2a10 mm/memory.c:1552
 unmap_single_vma+0x198/0x310 mm/memory.c:1597
 unmap_vmas+0x16d/0x2f0 mm/memory.c:1629
 exit_mmap+0x1d0/0x620 mm/mmap.c:3194
 __mmput+0x122/0x470 kernel/fork.c:1154
 mmput+0x58/0x60 kernel/fork.c:1175
 exit_mm kernel/exit.c:501 [inline]
 do_exit+0xabc/0x2a30 kernel/exit.c:812
 do_group_exit+0x125/0x310 kernel/exit.c:922
 get_signal+0x47f/0x2160 kernel/signal.c:2868
 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:865
 handle_signal_work kernel/entry/common.c:148 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
 exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:209
 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

kfence-#60: 0xffff88823bc7a740-0xffff88823bc7afd7, size=2200, cache=sighand_cache

allocated by task 8798 on cpu 0 at 2851.561024s:
 copy_sighand kernel/fork.c:1573 [inline]
 copy_process+0x2354/0x7580 kernel/fork.c:2165
 kernel_clone+0xe7/0xac0 kernel/fork.c:2561
 __do_sys_clone+0xc8/0x110 kernel/fork.c:2678
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

freed by task 8802 on cpu 0 at 2851.627381s:
 rcu_do_batch kernel/rcu/tree.c:2506 [inline]
 rcu_core+0x7ab/0x1470 kernel/rcu/tree.c:2741
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:636
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:648
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
 lock_acquire+0x1ef/0x510 kernel/locking/lockdep.c:5593
 rcu_lock_acquire include/linux/rcupdate.h:267 [inline]
 rcu_read_lock include/linux/rcupdate.h:687 [inline]
 folio_memcg_lock+0x3a/0x3e0 mm/memcontrol.c:1984
 page_remove_rmap+0x25/0x1480 mm/rmap.c:1348
 zap_pte_range mm/memory.c:1362 [inline]
 zap_pmd_range mm/memory.c:1481 [inline]
 zap_pud_range mm/memory.c:1510 [inline]
 zap_p4d_range mm/memory.c:1531 [inline]
 unmap_page_range+0xed5/0x2a10 mm/memory.c:1552
 unmap_single_vma+0x198/0x310 mm/memory.c:1597
 unmap_vmas+0x16d/0x2f0 mm/memory.c:1629
 exit_mmap+0x1d0/0x620 mm/mmap.c:3194
 __mmput+0x122/0x470 kernel/fork.c:1154
 mmput+0x58/0x60 kernel/fork.c:1175
 exit_mm kernel/exit.c:501 [inline]
 do_exit+0xabc/0x2a30 kernel/exit.c:812
 do_group_exit+0x125/0x310 kernel/exit.c:922
 get_signal+0x47f/0x2160 kernel/signal.c:2868
 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:865
 handle_signal_work kernel/entry/common.c:148 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
 exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:209
 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

CPU: 0 PID: 8802 Comm: syz-executor.4 Not tainted 5.14.0-next-20210901-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__lock_acquire+0xd87/0x54a0 kernel/locking/lockdep.c:4885
Code: c8 00 00 00 89 05 69 fd e9 0d e9 bd 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 da 48 c1 ea 03 80 3c 02 00 0f 85 f3 2f 00 00 <48> 81 3b 40 44 f0 8e 0f 84 52 f3 ff ff 41 83 fa 01 0f 87 5a f3 ff
RSP: 0018:ffffc90000007b60 EFLAGS: 00010046
RAX: dffffc0000000000 RBX: ffff88823bc7a7a0 RCX: 0000000000000000
RDX: 1ffff1104778f4f4 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: ffff8880799e8000 R14: 0000000000000000 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff88823bc7a7a0 CR3: 00000000782f2000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <IRQ>
 lock_acquire kernel/locking/lockdep.c:5625 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:368 [inline]
 aio_poll_cancel+0x3e/0x290 fs/aio.c:1661
 free_ioctx_users+0xa4/0x230 fs/aio.c:622
 percpu_ref_put_many.constprop.0+0x22b/0x260 include/linux/percpu-refcount.h:322
 rcu_do_batch kernel/rcu/tree.c:2506 [inline]
 rcu_core+0x7ab/0x1470 kernel/rcu/tree.c:2741
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:636
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:648
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
 </IRQ>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:lock_acquire+0x1ef/0x510 kernel/locking/lockdep.c:5593
Code: 95 a6 7e 83 f8 01 0f 85 b4 02 00 00 9c 58 f6 c4 02 0f 85 9f 02 00 00 48 83 7c 24 08 00 74 01 fb 48 b8 00 00 00 00 00 fc ff df <48> 01 c3 48 c7 03 00 00 00 00 48 c7 43 08 00 00 00 00 48 8b 84 24
RSP: 0018:ffffc90019d2f618 EFLAGS: 00000206
RAX: dffffc0000000000 RBX: 1ffff920033a5ec5 RCX: 42f1125c69a15e59
RDX: 1ffff1100f33d13f RSI: 0000000000000001 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffff8fd00927
R10: fffffbfff1fa0124 R11: 0000000000000000 R12: 0000000000000002
R13: 0000000000000000 R14: ffffffff8b97fbe0 R15: 0000000000000000
 rcu_lock_acquire include/linux/rcupdate.h:267 [inline]
 rcu_read_lock include/linux/rcupdate.h:687 [inline]
 folio_memcg_lock+0x3a/0x3e0 mm/memcontrol.c:1984
 page_remove_rmap+0x25/0x1480 mm/rmap.c:1348
 zap_pte_range mm/memory.c:1362 [inline]
 zap_pmd_range mm/memory.c:1481 [inline]
 zap_pud_range mm/memory.c:1510 [inline]
 zap_p4d_range mm/memory.c:1531 [inline]
 unmap_page_range+0xed5/0x2a10 mm/memory.c:1552
 unmap_single_vma+0x198/0x310 mm/memory.c:1597
 unmap_vmas+0x16d/0x2f0 mm/memory.c:1629
 exit_mmap+0x1d0/0x620 mm/mmap.c:3194
 __mmput+0x122/0x470 kernel/fork.c:1154
 mmput+0x58/0x60 kernel/fork.c:1175
 exit_mm kernel/exit.c:501 [inline]
 do_exit+0xabc/0x2a30 kernel/exit.c:812
 do_group_exit+0x125/0x310 kernel/exit.c:922
 get_signal+0x47f/0x2160 kernel/signal.c:2868
 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:865
 handle_signal_work kernel/entry/common.c:148 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
 exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:209
 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x4665f9
Code: Unable to access opcode bytes at RIP 0x4665cf.
RSP: 002b:00007f612d70a218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: 0000000000000001 RBX: 000000000056bf88 RCX: 00000000004665f9
RDX: 00000000000f4240 RSI: 0000000000000081 RDI: 000000000056bf8c
RBP: 000000000056bf80 R08: 000000000000000e R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf8c
R13: 00007ffc3ac4f64f R14: 00007f612d70a300 R15: 0000000000022000
==================================================================
----------------
Code disassembly (best guess):
   0:	c8 00 00 00          	enterq $0x0,$0x0
   4:	89 05 69 fd e9 0d    	mov    %eax,0xde9fd69(%rip)        # 0xde9fd73
   a:	e9 bd 00 00 00       	jmpq   0xcc
   f:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  16:	fc ff df
  19:	48 89 da             	mov    %rbx,%rdx
  1c:	48 c1 ea 03          	shr    $0x3,%rdx
  20:	80 3c 02 00          	cmpb   $0x0,(%rdx,%rax,1)
  24:	0f 85 f3 2f 00 00    	jne    0x301d
* 2a:	48 81 3b 40 44 f0 8e 	cmpq   $0xffffffff8ef04440,(%rbx) <-- trapping instruction
  31:	0f 84 52 f3 ff ff    	je     0xfffff389
  37:	41 83 fa 01          	cmp    $0x1,%r10d
  3b:	0f                   	.byte 0xf
  3c:	87 5a f3             	xchg   %ebx,-0xd(%rdx)
  3f:	ff                   	.byte 0xff

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2021/09/05 00:41 linux-next c1b13fe76e95 d236a457 .config log report info KFENCE: use-after-free in aio_poll_cancel
* Struck through repros no longer work on HEAD.