syzbot


possible deadlock in perf_swevent_init

Status: upstream: reported C repro on 2019/06/16 12:54
Reported-by: syzbot+8b9257288923f8787b58@syzkaller.appspotmail.com
First crash: 1985d, last: 1041d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-414 possible deadlock in perf_swevent_init C 107 1816d 2052d 0/1 public: reported C repro on 2019/04/10 16:04
Last patch testing requests (8)
Created Duration User Patch Repo Result
2023/02/09 15:32 15m retest repro linux-4.14.y report log
2023/02/09 14:32 9m retest repro linux-4.14.y report log
2023/02/09 13:32 9m retest repro linux-4.14.y report log
2023/02/09 12:32 9m retest repro linux-4.14.y report log
2022/09/19 07:29 14m retest repro linux-4.14.y report log
2022/09/19 06:29 13m retest repro linux-4.14.y report log
2022/09/19 05:29 10m retest repro linux-4.14.y report log
2022/09/19 04:29 14m retest repro linux-4.14.y report log
Fix bisection attempts (7)
Created Duration User Patch Repo Result
2020/06/30 00:08 0m bisect fix linux-4.14.y error job log
2020/05/30 23:30 23m bisect fix linux-4.14.y OK (0) job log log
2020/04/30 23:06 24m bisect fix linux-4.14.y OK (0) job log log
2020/03/31 21:47 22m bisect fix linux-4.14.y OK (0) job log log
2020/03/01 21:22 24m bisect fix linux-4.14.y OK (0) job log log
2020/01/31 17:11 25m bisect fix linux-4.14.y OK (0) job log log
2020/01/01 15:52 23m bisect fix linux-4.14.y OK (0) job log log

Sample crash report:
audit: type=1400 audit(1561664052.573:36): avc:  denied  { map } for  pid=6840 comm="syz-executor846" path="/root/syz-executor846538853" 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.131 #25 Not tainted
------------------------------------------------------
syz-executor846/6840 is trying to acquire lock:
 (pmus_lock){+.+.}, at: [<ffffffff816b6e6e>] swevent_hlist_get kernel/events/core.c:7891 [inline]
 (pmus_lock){+.+.}, at: [<ffffffff816b6e6e>] perf_swevent_init+0x12e/0x490 kernel/events/core.c:7951

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&cpuctx_mutex/1){+.+.}:
       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

-> #1 (&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

-> #0 (pmus_lock){+.+.}:
       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
       swevent_hlist_get kernel/events/core.c:7891 [inline]
       perf_swevent_init+0x12e/0x490 kernel/events/core.c:7951
       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

other info that might help us debug this:

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

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by syz-executor846/6840:
 #0:  (&pmus_srcu){....}, at: [<ffffffff816c0708>] perf_event_alloc.part.0+0xba8/0x2530 kernel/events/core.c:9636
 #1:  (&cpuctx_mutex/1){+.+.}, at: [<ffffffff816bb930>] perf_event_ctx_lock_nested+0x150/0x2c0 kernel/events/core.c:1235

stack backtrace:
CPU: 1 PID: 6840 Comm: syz-executor846 Not tainted 4.14.131 #25
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
 swevent_hlist_get kernel/events/core.c:7891 [inline]
 perf_swevent_init+0x12e/0x490 kernel/events/core.c:7951
 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
RIP: 0033:0x440569
RSP: 002b:00007ffc9b023b38 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440569
RDX: 000000000000

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/06/27 19:37 linux-4.14.y f4cc0ed9b2c7 7509bf36 .config console log report syz C ci2-linux-4-14
2019/06/20 07:26 linux-4.14.y bb263a2a2d43 34bf9440 .config console log report syz C ci2-linux-4-14
2019/06/17 12:59 linux-4.14.y a74d0e937a3a 442206d7 .config console log report syz ci2-linux-4-14
2019/06/16 11:53 linux-4.14.y a74d0e937a3a 442206d7 .config console log report syz ci2-linux-4-14
2022/01/15 17:29 linux-4.14.y 4ba8e26127c3 723cfaf0 .config console log report info ci2-linux-4-14 possible deadlock in perf_swevent_init
2019/12/02 15:52 linux-4.14.y fbc5fe7a54d0 f879db37 .config console log report ci2-linux-4-14
2019/11/25 11:13 linux-4.14.y 43598c571e7e 598ca6c8 .config console log report ci2-linux-4-14
2019/11/15 02:11 linux-4.14.y 775d01b65b5d 048f2d49 .config console log report ci2-linux-4-14
2019/11/14 13:14 linux-4.14.y 775d01b65b5d 048f2d49 .config console log report ci2-linux-4-14
2019/11/08 01:41 linux-4.14.y c9fda4f22428 f39aff9e .config console log report ci2-linux-4-14
2019/11/08 01:17 linux-4.14.y c9fda4f22428 f39aff9e .config console log report ci2-linux-4-14
2019/11/02 13:58 linux-4.14.y ddef1e8e3f6e 997ccc67 .config console log report ci2-linux-4-14
2019/09/04 21:06 linux-4.14.y 01fd1694b93c d994512d .config console log report ci2-linux-4-14
2019/09/01 12:21 linux-4.14.y 01fd1694b93c bad3cce2 .config console log report ci2-linux-4-14
2019/08/31 03:51 linux-4.14.y 01fd1694b93c bcd7bcc2 .config console log report ci2-linux-4-14
2019/08/30 11:35 linux-4.14.y 01fd1694b93c cd626f3b .config console log report ci2-linux-4-14
2019/08/16 00:47 linux-4.14.y 3ffe1e79c174 faeffb00 .config console log report ci2-linux-4-14
2019/06/20 06:16 linux-4.14.y bb263a2a2d43 34bf9440 .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.