====================================================== WARNING: possible circular locking dependency detected 4.19.90-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.1/31597 is trying to acquire lock: 000000005f5063aa (&mm->mmap_sem){++++}, at: __might_fault+0xfb/0x1e0 mm/memory.c:4637 but task is already holding lock: 00000000d4b60039 (&cpuctx_mutex){+.+.}, at: perf_event_ctx_lock_nested+0x259/0x460 kernel/events/core.c:1276 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&cpuctx_mutex){+.+.}: __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0xf7/0x1300 kernel/locking/mutex.c:1072 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 perf_event_init_cpu+0xcf/0x180 kernel/events/core.c:11745 perf_event_init+0x317/0x363 kernel/events/core.c:11792 start_kernel+0x505/0x8c5 init/main.c:645 x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:490 x86_64_start_kernel+0x77/0x7b arch/x86/kernel/head64.c:471 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243 -> #2 (pmus_lock){+.+.}: __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0xf7/0x1300 kernel/locking/mutex.c:1072 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 perf_event_init_cpu+0x2f/0x180 kernel/events/core.c:11739 cpuhp_invoke_callback+0x201/0x1af0 kernel/cpu.c:168 cpuhp_up_callbacks kernel/cpu.c:568 [inline] _cpu_up+0x270/0x540 kernel/cpu.c:1119 do_cpu_up kernel/cpu.c:1154 [inline] do_cpu_up+0xea/0x1c0 kernel/cpu.c:1126 cpu_up+0x1b/0x20 kernel/cpu.c:1162 smp_init+0x1a8/0x1c1 kernel/smp.c:578 kernel_init_freeable+0x339/0x5c8 init/main.c:1137 kernel_init+0x12/0x1bd init/main.c:1061 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415 -> #1 (cpu_hotplug_lock.rw_sem){++++}: percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline] percpu_down_read include/linux/percpu-rwsem.h:59 [inline] cpus_read_lock+0x3e/0xe0 kernel/cpu.c:288 __static_key_slow_dec kernel/jump_label.c:212 [inline] static_key_slow_dec+0x54/0xa0 kernel/jump_label.c:227 sw_perf_event_destroy+0x8b/0x130 kernel/events/core.c:8238 _free_event+0x354/0x1220 kernel/events/core.c:4453 put_event+0x47/0x60 kernel/events/core.c:4547 perf_mmap_close+0x789/0xe40 kernel/events/core.c:5547 remove_vma+0xb2/0x180 mm/mmap.c:182 remove_vma_list mm/mmap.c:2554 [inline] do_munmap+0x723/0xed0 mm/mmap.c:2790 mmap_region+0x224/0x1760 mm/mmap.c:1706 do_mmap+0x8e2/0x1080 mm/mmap.c:1536 do_mmap_pgoff include/linux/mm.h:2314 [inline] vm_mmap_pgoff+0x1c5/0x230 mm/util.c:357 ksys_mmap_pgoff+0x4aa/0x630 mm/mmap.c:1586 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:100 [inline] __se_sys_mmap arch/x86/kernel/sys_x86_64.c:91 [inline] __x64_sys_mmap+0xe9/0x1b0 arch/x86/kernel/sys_x86_64.c:91 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #0 (&mm->mmap_sem){++++}: lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3903 __might_fault mm/memory.c:4638 [inline] __might_fault+0x15e/0x1e0 mm/memory.c:4623 _copy_from_user+0x30/0x150 lib/usercopy.c:10 copy_from_user include/linux/uaccess.h:147 [inline] memdup_user+0x4e/0xb0 mm/util.c:164 strndup_user+0x77/0xd0 mm/util.c:217 perf_event_set_filter+0x9b/0xe40 kernel/events/core.c:9137 _perf_ioctl+0x439/0x12b0 kernel/events/core.c:5092 perf_ioctl+0x5c/0x90 kernel/events/core.c:5143 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:501 [inline] do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705 __do_sys_ioctl fs/ioctl.c:712 [inline] __se_sys_ioctl fs/ioctl.c:710 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710 do_syscall_64+0xfd/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.1/31597: #0: 00000000d4b60039 (&cpuctx_mutex){+.+.}, at: perf_event_ctx_lock_nested+0x259/0x460 kernel/events/core.c:1276 stack backtrace: CPU: 1 PID: 31597 Comm: syz-executor.1 Not tainted 4.19.90-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+0x197/0x210 lib/dump_stack.c:118 print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1221 check_prev_add kernel/locking/lockdep.c:1861 [inline] check_prevs_add kernel/locking/lockdep.c:1974 [inline] validate_chain kernel/locking/lockdep.c:2415 [inline] __lock_acquire+0x2e19/0x49c0 kernel/locking/lockdep.c:3411 lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3903 __might_fault mm/memory.c:4638 [inline] __might_fault+0x15e/0x1e0 mm/memory.c:4623 _copy_from_user+0x30/0x150 lib/usercopy.c:10 copy_from_user include/linux/uaccess.h:147 [inline] memdup_user+0x4e/0xb0 mm/util.c:164 strndup_user+0x77/0xd0 mm/util.c:217 perf_event_set_filter+0x9b/0xe40 kernel/events/core.c:9137 _perf_ioctl+0x439/0x12b0 kernel/events/core.c:5092 perf_ioctl+0x5c/0x90 kernel/events/core.c:5143 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:501 [inline] do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705 __do_sys_ioctl fs/ioctl.c:712 [inline] __se_sys_ioctl fs/ioctl.c:710 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x45a919 Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f5d4c533c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a919 RDX: 0000000020002940 RSI: 0000000040082406 RDI: 0000000000000008 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5d4c5346d4 R13: 00000000004cfd48 R14: 00000000004da038 R15: 00000000ffffffff kobject: 'loop5' (000000005c452079): kobject_uevent_env kobject: 'loop5' (000000005c452079): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop1' (0000000031420c14): kobject_uevent_env kobject: 'loop1' (0000000031420c14): fill_kobj_path: path = '/devices/virtual/block/loop1' selinux_nlmsg_perm: 60 callbacks suppressed SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop4' (0000000067c2dadb): kobject_uevent_env kobject: 'loop4' (0000000067c2dadb): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop1' (0000000031420c14): kobject_uevent_env kobject: 'loop1' (0000000031420c14): fill_kobj_path: path = '/devices/virtual/block/loop1' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31769 comm=syz-executor.5 kobject: 'loop3' (000000009725998d): kobject_uevent_env kobject: 'loop3' (000000009725998d): fill_kobj_path: path = '/devices/virtual/block/loop3' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop1' (0000000031420c14): kobject_uevent_env SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31769 comm=syz-executor.5 kobject: 'loop1' (0000000031420c14): fill_kobj_path: path = '/devices/virtual/block/loop1' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop3' (000000009725998d): kobject_uevent_env SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop3' (000000009725998d): fill_kobj_path: path = '/devices/virtual/block/loop3' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=31713 comm=syz-executor.5 kobject: 'loop5' (000000005c452079): kobject_uevent_env kobject: 'loop5' (000000005c452079): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop4' (0000000067c2dadb): kobject_uevent_env kobject: 'loop4' (0000000067c2dadb): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop5' (000000005c452079): kobject_uevent_env kobject: 'loop5' (000000005c452079): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop1' (0000000031420c14): kobject_uevent_env kobject: 'loop1' (0000000031420c14): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'loop3' (000000009725998d): kobject_uevent_env kobject: 'loop3' (000000009725998d): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop5' (000000005c452079): kobject_uevent_env kobject: 'loop5' (000000005c452079): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop5' (000000005c452079): kobject_uevent_env kobject: 'loop5' (000000005c452079): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop4' (0000000067c2dadb): kobject_uevent_env kobject: 'loop4' (0000000067c2dadb): fill_kobj_path: path = '/devices/virtual/block/loop4' selinux_nlmsg_perm: 42 callbacks suppressed SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32743 comm=syz-executor.5 kobject: 'loop1' (0000000031420c14): kobject_uevent_env kobject: 'loop1' (0000000031420c14): fill_kobj_path: path = '/devices/virtual/block/loop1' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=311 comm=syz-executor.5 kobject: 'loop3' (000000009725998d): kobject_uevent_env kobject: 'loop3' (000000009725998d): fill_kobj_path: path = '/devices/virtual/block/loop3' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 kobject: 'loop1' (0000000031420c14): kobject_uevent_env kobject: 'loop1' (0000000031420c14): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'loop3' (000000009725998d): kobject_uevent_env SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32743 comm=syz-executor.5 kobject: 'loop3' (000000009725998d): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop2' (00000000caf97667): kobject_uevent_env kobject: 'loop2' (00000000caf97667): fill_kobj_path: path = '/devices/virtual/block/loop2' SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 SELinux: unrecognized netlink message: protocol=0 nlmsg_type=14962 sclass=netlink_route_socket pig=32554 comm=syz-executor.5 kobject: 'loop5' (000000005c452079): kobject_uevent_env kobject: 'loop5' (000000005c452079): fill_kobj_path: path = '/devices/virtual/block/loop5'