syzbot


possible deadlock in perf_event_ctx_lock_nested (2)

Status: upstream: reported syz repro on 2020/10/20 10:26
Reported-by: syzbot+0f6f2030b58054a9a2aa@syzkaller.appspotmail.com
First crash: 1495d, last: 694d
Fix bisection: failed (error log, bisect log)
  
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 628d 723d 0/1 upstream: reported C repro on 2022/12/01 07:26
linux-4.19 possible deadlock in perf_event_ctx_lock_nested 1 1324d 1324d 0/1 auto-closed as invalid on 2021/08/06 16:06
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
Fix bisection attempts (23)
Created Duration User Patch Repo Result
2023/02/03 12:55 0m bisect fix linux-4.14.y error job log
2022/10/29 11:25 26m bisect fix linux-4.14.y OK (0) job log log
2022/09/16 01:39 25m bisect fix linux-4.14.y OK (0) job log log
2022/08/17 01:10 24m bisect fix linux-4.14.y OK (0) job log log
2022/07/18 00:39 30m bisect fix linux-4.14.y OK (0) job log log
2022/06/18 00:04 34m bisect fix linux-4.14.y OK (0) job log log
2022/05/18 18:34 26m bisect fix linux-4.14.y OK (0) job log log
2022/04/18 16:45 25m bisect fix linux-4.14.y OK (0) job log log
2022/03/19 15:59 32m bisect fix linux-4.14.y OK (0) job log log
2022/02/17 04:21 25m bisect fix linux-4.14.y OK (0) job log log
2021/12/30 00:39 28m bisect fix linux-4.14.y OK (0) job log log
2021/11/30 00:01 26m bisect fix linux-4.14.y OK (0) job log log
2021/10/30 23:35 25m bisect fix linux-4.14.y OK (0) job log log
2021/09/23 09:20 27m bisect fix linux-4.14.y OK (0) job log log
2021/08/24 08:32 29m bisect fix linux-4.14.y OK (0) job log log
2021/07/25 03:54 26m bisect fix linux-4.14.y OK (0) job log log
2021/06/25 00:39 23m bisect fix linux-4.14.y OK (0) job log log
2021/05/25 23:37 28m bisect fix linux-4.14.y OK (0) job log log
2021/04/25 23:07 29m bisect fix linux-4.14.y OK (0) job log log
2021/02/25 06:02 23m bisect fix linux-4.14.y OK (0) job log log
2021/01/18 15:21 22m bisect fix linux-4.14.y OK (0) job log log
2020/12/19 11:27 24m bisect fix linux-4.14.y OK (0) job log log
2020/11/19 11:04 23m bisect fix linux-4.14.y OK (0) job log log

Sample crash report:
IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
======================================================
WARNING: possible circular locking dependency detected
4.14.198-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/6620 is trying to acquire lock:
 (event_mutex){+.+.}, at: [<ffffffff816179af>] perf_trace_init+0x4f/0xa30 kernel/trace/trace_event_perf.c:216

but task is already holding lock:
 (&cpuctx_mutex/1){+.+.}, at: [<ffffffff8169c9fd>] perf_event_ctx_lock_nested+0x14d/0x2c0 kernel/events/core.c:1240

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&cpuctx_mutex/1){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       mutex_lock_double kernel/events/core.c:9930 [inline]
       __perf_event_ctx_lock_double kernel/events/core.c:9989 [inline]
       SYSC_perf_event_open kernel/events/core.c:10251 [inline]
       SyS_perf_event_open+0xd28/0x24b0 kernel/events/core.c:10009
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #4 (&cpuctx_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       perf_event_init_cpu+0xb7/0x170 kernel/events/core.c:11249
       perf_event_init+0x2cc/0x308 kernel/events/core.c:11296
       start_kernel+0x46a/0x770 init/main.c:620
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:240

-> #3 (pmus_lock){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       perf_event_init_cpu+0x2c/0x170 kernel/events/core.c:11243
       cpuhp_invoke_callback+0x1e6/0x1a80 kernel/cpu.c:184
       cpuhp_up_callbacks kernel/cpu.c:572 [inline]
       _cpu_up+0x219/0x500 kernel/cpu.c:1140
       do_cpu_up+0x9a/0x160 kernel/cpu.c:1175
       smp_init+0x197/0x1ac kernel/smp.c:578
       kernel_init_freeable+0x3f4/0x619 init/main.c:1068
       kernel_init+0xd/0x15b init/main.c:1000
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #2 (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+0x39/0xc0 kernel/cpu.c:295
       static_key_slow_inc+0xe/0x20 kernel/jump_label.c:123
       tracepoint_add_func+0x517/0x750 kernel/tracepoint.c:223
       tracepoint_probe_register_prio kernel/tracepoint.c:283 [inline]
       tracepoint_probe_register+0x8c/0xc0 kernel/tracepoint.c:304
       trace_event_reg+0x272/0x330 kernel/trace/trace_events.c:305
       perf_trace_event_reg kernel/trace/trace_event_perf.c:122 [inline]
       perf_trace_event_init kernel/trace/trace_event_perf.c:197 [inline]
       perf_trace_init+0x424/0xa30 kernel/trace/trace_event_perf.c:221
       perf_tp_event_init+0x79/0xf0 kernel/events/core.c:8132
       perf_try_init_event+0x15b/0x1f0 kernel/events/core.c:9368
       perf_init_event kernel/events/core.c:9406 [inline]
       perf_event_alloc.part.0+0xe2d/0x2640 kernel/events/core.c:9666
       perf_event_alloc kernel/events/core.c:10019 [inline]
       SYSC_perf_event_open kernel/events/core.c:10123 [inline]
       SyS_perf_event_open+0x67f/0x24b0 kernel/events/core.c:10009
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #1 (tracepoints_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       tracepoint_probe_register_prio kernel/tracepoint.c:279 [inline]
       tracepoint_probe_register+0x68/0xc0 kernel/tracepoint.c:304
       trace_event_reg+0x272/0x330 kernel/trace/trace_events.c:305
       perf_trace_event_reg kernel/trace/trace_event_perf.c:122 [inline]
       perf_trace_event_init kernel/trace/trace_event_perf.c:197 [inline]
       perf_trace_init+0x424/0xa30 kernel/trace/trace_event_perf.c:221
       perf_tp_event_init+0x79/0xf0 kernel/events/core.c:8132
       perf_try_init_event+0x15b/0x1f0 kernel/events/core.c:9368
       perf_init_event kernel/events/core.c:9406 [inline]
       perf_event_alloc.part.0+0xe2d/0x2640 kernel/events/core.c:9666
       perf_event_alloc kernel/events/core.c:10019 [inline]
       SYSC_perf_event_open kernel/events/core.c:10123 [inline]
       SyS_perf_event_open+0x67f/0x24b0 kernel/events/core.c:10009
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #0 (event_mutex){+.+.}:
       lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       perf_trace_init+0x4f/0xa30 kernel/trace/trace_event_perf.c:216
       perf_tp_event_init+0x79/0xf0 kernel/events/core.c:8132
       perf_try_init_event+0xdf/0x1f0 kernel/events/core.c:9368
       perf_init_event kernel/events/core.c:9406 [inline]
       perf_event_alloc.part.0+0xe2d/0x2640 kernel/events/core.c:9666
       perf_event_alloc kernel/events/core.c:10019 [inline]
       SYSC_perf_event_open kernel/events/core.c:10123 [inline]
       SyS_perf_event_open+0x67f/0x24b0 kernel/events/core.c:10009
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

other info that might help us debug this:

Chain exists of:
  event_mutex --> &cpuctx_mutex --> &cpuctx_mutex/1

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&cpuctx_mutex/1);
                               lock(&cpuctx_mutex);
                               lock(&cpuctx_mutex/1);
  lock(event_mutex);

 *** DEADLOCK ***

2 locks held by syz-executor.0/6620:
 #0:  (&pmus_srcu){....}, at: [<ffffffff816a05e4>] fdput include/linux/file.h:39 [inline]
 #0:  (&pmus_srcu){....}, at: [<ffffffff816a05e4>] perf_cgroup_connect kernel/events/core.c:848 [inline]
 #0:  (&pmus_srcu){....}, at: [<ffffffff816a05e4>] perf_event_alloc.part.0+0xc44/0x2640 kernel/events/core.c:9661
 #1:  (&cpuctx_mutex/1){+.+.}, at: [<ffffffff8169c9fd>] perf_event_ctx_lock_nested+0x14d/0x2c0 kernel/events/core.c:1240

stack backtrace:
CPU: 0 PID: 6620 Comm: syz-executor.0 Not tainted 4.14.198-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1905 [inline]
 check_prevs_add kernel/locking/lockdep.c:2022 [inline]
 validate_chain kernel/locking/lockdep.c:2464 [inline]
 __lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491
 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
 perf_trace_init+0x4f/0xa30 kernel/trace/trace_event_perf.c:216
 perf_tp_event_init+0x79/0xf0 kernel/events/core.c:8132
 perf_try_init_event+0xdf/0x1f0 kernel/events/core.c:9368
 perf_init_event kernel/events/core.c:9406 [inline]
 perf_event_alloc.part.0+0xe2d/0x2640 kernel/events/core.c:9666
 perf_event_alloc kernel/events/core.c:10019 [inline]
 SYSC_perf_event_open kernel/events/core.c:10123 [inline]
 SyS_perf_event_open+0x67f/0x24b0 kernel/events/core.c:10009
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x45de59
RSP: 002b:00007fa5fad12c78 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 0000000000024cc0 RCX: 000000000045de59
RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 0000000020000040
RBP: 000000000118bf70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000004 R11: 0000000000000246 R12: 000000000118bf2c
R13: 00007fffece8105f R14: 00007fa5fad139c0 R15: 000000000118bf2c

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/10/20 11:03 linux-4.14.y cbfa1702aaf6 ff4a3345 .config console log report syz ci2-linux-4-14
2022/12/29 19:20 linux-4.14.y c4215ee4771b 44712fbc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in perf_event_ctx_lock_nested
2022/01/18 04:21 linux-4.14.y 4ba8e26127c3 731a2d23 .config console log report info ci2-linux-4-14 possible deadlock in perf_event_ctx_lock_nested
2022/01/14 07:56 linux-4.14.y 4ba8e26127c3 b8d780ab .config console log report info ci2-linux-4-14 possible deadlock in perf_event_ctx_lock_nested
2021/03/26 01:15 linux-4.14.y 670d6552eda8 6a383ecf .config console log report info ci2-linux-4-14 possible deadlock in perf_event_ctx_lock_nested
2020/10/20 10:25 linux-4.14.y cbfa1702aaf6 ff4a3345 .config console log report info ci2-linux-4-14
* Struck through repros no longer work on HEAD.