syzbot


possible deadlock in SYSC_perf_event_open

Status: upstream: reported C repro on 2019/04/24 19:45
Reported-by: syzbot+2b3d2f0be56bb53380f1@syzkaller.appspotmail.com
First crash: 2073d, last: 1672d
Fix bisection the fix commit could be any of (bisect log):
  2bf3258a12af Linux 4.14.125
  4139fb08c05f Linux 4.14.187
  
Last patch testing requests (6)
Created Duration User Patch Repo Result
2022/12/31 17:31 8m retest repro linux-4.14.y report log
2022/12/31 06:31 12m retest repro linux-4.14.y report log
2022/12/30 21:31 14m retest repro linux-4.14.y report log
2022/09/01 03:27 12m retest repro linux-4.14.y report log
2022/09/01 01:27 10m retest repro linux-4.14.y report log
2022/09/01 00:27 10m retest repro linux-4.14.y report log
Fix bisection attempts (7)
Created Duration User Patch Repo Result
2020/06/28 07:56 29m (3) bisect fix linux-4.14.y OK (2) job log
2020/05/29 07:15 22m bisect fix linux-4.14.y OK (0) job log log
2020/04/29 06:29 23m bisect fix linux-4.14.y OK (0) job log log
2020/03/30 05:57 22m bisect fix linux-4.14.y OK (0) job log log
2020/02/29 05:30 26m bisect fix linux-4.14.y OK (0) job log log
2020/01/30 05:04 26m bisect fix linux-4.14.y OK (0) job log log
2019/12/31 04:40 23m bisect fix linux-4.14.y OK (0) job log log

Sample crash report:
random: sshd: uninitialized urandom read (32 bytes read)
audit: type=1400 audit(1560559242.530:36): avc:  denied  { map } for  pid=7164 comm="syz-executor584" path="/root/syz-executor584840997" dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
======================================================
WARNING: possible circular locking dependency detected
4.14.125 #19 Not tainted
------------------------------------------------------
syz-executor584/7164 is trying to acquire lock:
 (&cpuctx_mutex/1){+.+.}, at: [<ffffffff816d369f>] mutex_lock_double kernel/events/core.c:9904 [inline]
 (&cpuctx_mutex/1){+.+.}, at: [<ffffffff816d369f>] __perf_event_ctx_lock_double kernel/events/core.c:9963 [inline]
 (&cpuctx_mutex/1){+.+.}, at: [<ffffffff816d369f>] SYSC_perf_event_open+0x121f/0x24b0 kernel/events/core.c:10225

but task is already holding lock:
 (&cpuctx_mutex){+.+.}, at: [<ffffffff816d3692>] mutex_lock_double kernel/events/core.c:9903 [inline]
 (&cpuctx_mutex){+.+.}, at: [<ffffffff816d3692>] __perf_event_ctx_lock_double kernel/events/core.c:9963 [inline]
 (&cpuctx_mutex){+.+.}, at: [<ffffffff816d3692>] SYSC_perf_event_open+0x1212/0x24b0 kernel/events/core.c:10225

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&cpuctx_mutex){+.+.}:
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       perf_event_init_cpu+0xc2/0x170 kernel/events/core.c:11223
       perf_event_init+0x2d8/0x31a kernel/events/core.c:11270
       start_kernel+0x3b6/0x6fd init/main.c:621
       x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:380
       x86_64_start_kernel+0x77/0x7b arch/x86/kernel/head64.c:361
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:240

-> #4 (pmus_lock){+.+.}:
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       perf_event_init_cpu+0x2f/0x170 kernel/events/core.c:11217
       cpuhp_invoke_callback+0x1ea/0x1ab0 kernel/cpu.c:184
       cpuhp_up_callbacks kernel/cpu.c:572 [inline]
       _cpu_up+0x228/0x530 kernel/cpu.c:1134
       do_cpu_up+0x121/0x150 kernel/cpu.c:1169
       cpu_up+0x1b/0x20 kernel/cpu.c:1177
       smp_init+0x157/0x170 kernel/smp.c:578
       kernel_init_freeable+0x30b/0x532 init/main.c:1067
       kernel_init+0x12/0x162 init/main.c:999
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #3 (cpu_hotplug_lock.rw_sem){++++}:
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
       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+0x3d/0xc0 kernel/cpu.c:295
       static_key_slow_inc+0x13/0x30 kernel/jump_label.c:123
       tracepoint_add_func kernel/tracepoint.c:223 [inline]
       tracepoint_probe_register_prio+0x4d6/0x6d0 kernel/tracepoint.c:283
       tracepoint_probe_register+0x2b/0x40 kernel/tracepoint.c:304
       trace_event_reg+0x277/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+0x449/0xaa0 kernel/trace/trace_event_perf.c:221
       perf_tp_event_init+0x7d/0xf0 kernel/events/core.c:8106
       perf_try_init_event+0x164/0x200 kernel/events/core.c:9342
       perf_init_event kernel/events/core.c:9380 [inline]
       perf_event_alloc.part.0+0xd48/0x2530 kernel/events/core.c:9640
       perf_event_alloc kernel/events/core.c:9993 [inline]
       SYSC_perf_event_open+0xa2d/0x24b0 kernel/events/core.c:10097
       SyS_perf_event_open+0x34/0x40 kernel/events/core.c:9983
       do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #2 (tracepoints_mutex){+.+.}:
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       tracepoint_probe_register_prio+0x36/0x6d0 kernel/tracepoint.c:279
       tracepoint_probe_register+0x2b/0x40 kernel/tracepoint.c:304
       trace_event_reg+0x277/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+0x449/0xaa0 kernel/trace/trace_event_perf.c:221
       perf_tp_event_init+0x7d/0xf0 kernel/events/core.c:8106
       perf_try_init_event+0x164/0x200 kernel/events/core.c:9342
       perf_init_event kernel/events/core.c:9380 [inline]
       perf_event_alloc.part.0+0xd48/0x2530 kernel/events/core.c:9640
       perf_event_alloc kernel/events/core.c:9993 [inline]
       SYSC_perf_event_open+0xa2d/0x24b0 kernel/events/core.c:10097
       SyS_perf_event_open+0x34/0x40 kernel/events/core.c:9983
       do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #1 (event_mutex){+.+.}:
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       perf_trace_init+0x58/0xaa0 kernel/trace/trace_event_perf.c:216
       perf_tp_event_init+0x7d/0xf0 kernel/events/core.c:8106
       perf_try_init_event+0xe6/0x200 kernel/events/core.c:9342
       perf_init_event kernel/events/core.c:9380 [inline]
       perf_event_alloc.part.0+0xd48/0x2530 kernel/events/core.c:9640
       perf_event_alloc kernel/events/core.c:9993 [inline]
       SYSC_perf_event_open+0xa2d/0x24b0 kernel/events/core.c:10097
       SyS_perf_event_open+0x34/0x40 kernel/events/core.c:9983
       do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #0 (&cpuctx_mutex/1){+.+.}:
       check_prev_add kernel/locking/lockdep.c:1901 [inline]
       check_prevs_add kernel/locking/lockdep.c:2018 [inline]
       validate_chain kernel/locking/lockdep.c:2460 [inline]
       __lock_acquire+0x2c89/0x45e0 kernel/locking/lockdep.c:3487
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       mutex_lock_double kernel/events/core.c:9904 [inline]
       __perf_event_ctx_lock_double kernel/events/core.c:9963 [inline]
       SYSC_perf_event_open+0x121f/0x24b0 kernel/events/core.c:10225
       SyS_perf_event_open+0x34/0x40 kernel/events/core.c:9983
       do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

other info that might help us debug this:

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

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

1 lock held by syz-executor584/7164:
 #0:  (&cpuctx_mutex){+.+.}, at: [<ffffffff816d3692>] mutex_lock_double kernel/events/core.c:9903 [inline]
 #0:  (&cpuctx_mutex){+.+.}, at: [<ffffffff816d3692>] __perf_event_ctx_lock_double kernel/events/core.c:9963 [inline]
 #0:  (&cpuctx_mutex){+.+.}, at: [<ffffffff816d3692>] SYSC_perf_event_open+0x1212/0x24b0 kernel/events/core.c:10225

stack backtrace:
CPU: 0 PID: 7164 Comm: syz-executor584 Not tainted 4.14.125 #19
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+0x138/0x19c lib/dump_stack.c:53
 print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1901 [inline]
 check_prevs_add kernel/locking/lockdep.c:2018 [inline]
 validate_chain kernel/locking/lockdep.c:2460 [inline]
 __lock_acquire+0x2c89/0x45e0 kernel/locking/lockdep.c:3487
 lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3991
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
 mutex_lock_double kernel/events/core.c:9904 [inline]
 __perf_event_ctx_lock_double kernel/events/core.c:9963 [inline]
 SYSC_perf_event_open+0x121f/0x24b0 kernel/events/core.c:10225
 SyS_perf_event_open+0x34/0x40 kernel/events/core.c:9983
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x440579
RSP: 002b:00007ffde2bf1288 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440579
RDX: 0000000000000000 RSI: 00000000ffffffff RDI: 0000000020000200
RBP: 00000000006ca018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000401e00
R13: 0000000000401e90 R14: 0000000000000000 R15: 0000000000000000

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/06/15 00:45 linux-4.14.y 2bf3258a12af 442206d7 .config console log report syz C ci2-linux-4-14
2019/08/23 10:53 linux-4.14.y 45f092f9e9cb ca6f3cfa .config console log report syz ci2-linux-4-14
2019/04/24 18:44 linux-4.14.y 68d7a45eec10 8e3c52b1 .config console log report syz ci2-linux-4-14
2019/11/30 21:53 linux-4.14.y 43598c571e7e a76bf83f .config console log report ci2-linux-4-14
2019/07/20 22:03 linux-4.14.y aea8526edf59 1656845f .config console log report ci2-linux-4-14
2019/06/14 23:41 linux-4.14.y 2bf3258a12af 442206d7 .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.