syzbot


possible deadlock in perf_event_ctx_lock_nested

Status: auto-closed as invalid on 2021/08/06 16:06
Reported-by: syzbot+ed5fe3b5198362441e20@syzkaller.appspotmail.com
First crash: 1324d, last: 1324d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in perf_event_ctx_lock_nested perf 8914 2534d 2584d 0/28 auto-closed as invalid on 2019/02/22 10:22
linux-4.19 possible deadlock in perf_event_ctx_lock_nested (2) btrfs C 51 627d 723d 0/1 upstream: reported C repro on 2022/12/01 07:26
linux-4.14 possible deadlock in perf_event_ctx_lock_nested (2) syz error 6 694d 1495d 0/1 upstream: reported syz repro on 2020/10/20 10:26
upstream possible deadlock in perf_event_ctx_lock_nested (2) perf syz done 12 1129d 1286d 0/28 auto-obsoleted due to no activity on 2022/10/17 08:54
linux-4.14 possible deadlock in perf_event_ctx_lock_nested 1 1635d 1635d 0/1 auto-closed as invalid on 2020/09/30 09:36

Sample crash report:
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
======================================================
WARNING: possible circular locking dependency detected
4.19.185-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/1842 is trying to acquire lock:
00000000a0f81fc6 (&mm->mmap_sem){++++}, at: __might_fault+0xef/0x1d0 mm/memory.c:4730

but task is already holding lock:
00000000916d7464 (&cpuctx_mutex){+.+.}, at: perf_event_ctx_lock_nested+0x237/0x430 kernel/events/core.c:1283

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&cpuctx_mutex){+.+.}:
       perf_event_init_cpu+0xc4/0x170 kernel/events/core.c:11804
       perf_event_init+0x309/0x34e kernel/events/core.c:11851
       start_kernel+0x5b1/0x911 init/main.c:644
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #2 (pmus_lock){+.+.}:
       perf_event_init_cpu+0x2c/0x170 kernel/events/core.c:11798
       cpuhp_invoke_callback+0x201/0x1b80 kernel/cpu.c:169
       cpuhp_up_callbacks kernel/cpu.c:583 [inline]
       _cpu_up+0x257/0x510 kernel/cpu.c:1144
       do_cpu_up+0xdd/0x1b0 kernel/cpu.c:1179
       smp_init+0x1ed/0x202 kernel/smp.c:578
       kernel_init_freeable+0x60c/0xa98 init/main.c:1138
       kernel_init+0xd/0x1b6 init/main.c:1062
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

-> #1 (cpu_hotplug_lock.rw_sem){++++}:
       __static_key_slow_dec kernel/jump_label.c:222 [inline]
       static_key_slow_dec+0x4f/0x90 kernel/jump_label.c:237
       sw_perf_event_destroy+0x8a/0x120 kernel/events/core.c:8287
       _free_event+0x32c/0x1150 kernel/events/core.c:4460
       put_event kernel/events/core.c:4554 [inline]
       perf_mmap_close+0x6f6/0xea0 kernel/events/core.c:5558
       remove_vma+0xa9/0x170 mm/mmap.c:176
       remove_vma_list mm/mmap.c:2550 [inline]
       do_munmap+0x6f9/0xde0 mm/mmap.c:2786
       mmap_region+0x2a3/0x16b0 mm/mmap.c:1700
       do_mmap+0x8e8/0x1080 mm/mmap.c:1530
       do_mmap_pgoff include/linux/mm.h:2326 [inline]
       vm_mmap_pgoff+0x197/0x200 mm/util.c:357
       ksys_mmap_pgoff+0x298/0x5a0 mm/mmap.c:1580
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&mm->mmap_sem){++++}:
       __might_fault mm/memory.c:4731 [inline]
       __might_fault+0x152/0x1d0 mm/memory.c:4716
       _copy_to_user+0x29/0x100 lib/usercopy.c:25
       copy_to_user include/linux/uaccess.h:155 [inline]
       perf_read_group kernel/events/core.c:4807 [inline]
       __perf_read kernel/events/core.c:4874 [inline]
       perf_read+0x699/0x860 kernel/events/core.c:4889
       do_loop_readv_writev fs/read_write.c:701 [inline]
       do_loop_readv_writev fs/read_write.c:688 [inline]
       do_iter_read+0x471/0x630 fs/read_write.c:925
       vfs_readv+0xe5/0x150 fs/read_write.c:987
       do_readv+0x136/0x330 fs/read_write.c:1020
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

Chain exists of:
  &mm->mmap_sem --> pmus_lock --> &cpuctx_mutex

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&cpuctx_mutex);
                               lock(pmus_lock);
                               lock(&cpuctx_mutex);
  lock(&mm->mmap_sem);

 *** DEADLOCK ***

1 lock held by syz-executor.0/1842:
 #0: 00000000916d7464 (&cpuctx_mutex){+.+.}, at: perf_event_ctx_lock_nested+0x237/0x430 kernel/events/core.c:1283

stack backtrace:
CPU: 0 PID: 1842 Comm: syz-executor.0 Not tainted 4.19.185-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1221
 check_prev_add kernel/locking/lockdep.c:1865 [inline]
 check_prevs_add kernel/locking/lockdep.c:1978 [inline]
 validate_chain kernel/locking/lockdep.c:2419 [inline]
 __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3415
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3907
 __might_fault mm/memory.c:4731 [inline]
 __might_fault+0x152/0x1d0 mm/memory.c:4716
 _copy_to_user+0x29/0x100 lib/usercopy.c:25
 copy_to_user include/linux/uaccess.h:155 [inline]
 perf_read_group kernel/events/core.c:4807 [inline]
 __perf_read kernel/events/core.c:4874 [inline]
 perf_read+0x699/0x860 kernel/events/core.c:4889
 do_loop_readv_writev fs/read_write.c:701 [inline]
 do_loop_readv_writev fs/read_write.c:688 [inline]
 do_iter_read+0x471/0x630 fs/read_write.c:925
 vfs_readv+0xe5/0x150 fs/read_write.c:987
 do_readv+0x136/0x330 fs/read_write.c:1020
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x466459
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ff7781a8188 EFLAGS: 00000246 ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000466459
RDX: 0000000000000001 RSI: 00000000200002c0 RDI: 0000000000000006
RBP: 00000000004bf9fb R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf60
R13: 00007ffe6f9c469f R14: 00007ff7781a8300 R15: 0000000000022000
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
Restarting kernel threads ... done.
Restarting kernel threads ... 
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
done.
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
audit: type=1804 audit(1617897966.928:78): pid=1920 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir690230330/syzkaller.Mm34R6/1238/bus" dev="sda1" ino=14364 res=1
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
overlayfs: unrecognized mount option "0xffffffffffffffff" or missing value
tmpfs: Bad mount option *I͇f-D3:C|uP.
e{Ըfwod%@DIyzIBэ(g
overlayfs: unrecognized mount option "0xffffffffffffffff" or missing value
tmpfs: Bad mount option *I͇f-D3:C|uP.
e{Ըfwod%@DIyzIBэ(g
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
overlayfs: unrecognized mount option "lwerdir=.:file0" or missing value
overlayfs: unrecognized mount option "uppeidir=./bus" or missing value
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
overlayfs: unrecognized mount option "lwerdir=.:file0" or missing value
overlayfs: unrecognized mount option "uppeidir=./bus" or missing value
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
overlayfs: unrecognized mount option "w1" or missing value
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
overlayfs: unrecognized mount option "w1" or missing value
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22
gfs2: fsid=_dev_bsg: Trying to join cluster "lock_nolock", "_dev_bsg"
gfs2: fsid=_dev_bsg: Now mounting FS...
gfs2: not a GFS2 filesystem
gfs2: fsid=_dev_bsg: can't read superblock
gfs2: fsid=_dev_bsg: can't read superblock: -22

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/04/08 16:06 linux-4.19.y b4454811f122 6a81331a .config console log report info ci2-linux-4-19 possible deadlock in perf_event_ctx_lock_nested
* Struck through repros no longer work on HEAD.