======================================================
WARNING: possible circular locking dependency detected
4.14.142+ #0 Not tainted
------------------------------------------------------
syz-executor.4/29431 is trying to acquire lock:
 (pmus_lock){+.+.}, at: [<0000000035e9e035>] swevent_hlist_get kernel/events/core.c:7896 [inline]
 (pmus_lock){+.+.}, at: [<0000000035e9e035>] perf_swevent_init+0x123/0x4f0 kernel/events/core.c:7956

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&cpuctx_mutex/1){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xf7/0x13e0 kernel/locking/mutex.c:893
       mutex_lock_double kernel/events/core.c:9909 [inline]
       __perf_event_ctx_lock_double kernel/events/core.c:9968 [inline]
       SYSC_perf_event_open kernel/events/core.c:10233 [inline]
       SyS_perf_event_open+0x12cf/0x2560 kernel/events/core.c:9988
       do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #1 (&cpuctx_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xf7/0x13e0 kernel/locking/mutex.c:893
       perf_event_init_cpu+0xa8/0x150 kernel/events/core.c:11231
       perf_event_init+0x289/0x2c5 kernel/events/core.c:11278
       start_kernel+0x583/0x890 init/main.c:645
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:240

-> #0 (pmus_lock){+.+.}:
       lock_acquire+0x12b/0x360 kernel/locking/lockdep.c:3991
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xf7/0x13e0 kernel/locking/mutex.c:893
       swevent_hlist_get kernel/events/core.c:7896 [inline]
       perf_swevent_init+0x123/0x4f0 kernel/events/core.c:7956
       perf_try_init_event+0xe5/0x200 kernel/events/core.c:9347
       perf_init_event kernel/events/core.c:9385 [inline]
       perf_event_alloc.part.0+0xd13/0x1ff0 kernel/events/core.c:9645
       perf_event_alloc kernel/events/core.c:9998 [inline]
       SYSC_perf_event_open kernel/events/core.c:10105 [inline]
       SyS_perf_event_open+0x6eb/0x2560 kernel/events/core.c:9988
       do_syscall_64+0x19b/0x520 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-executor.4/29431:
 #0:  (&pmus_srcu){....}, at: [<00000000d5c6b6ff>] perf_event_alloc.part.0+0xb2b/0x1ff0 kernel/events/core.c:9639
 #1:  (&cpuctx_mutex/1){+.+.}, at: [<00000000a1b13894>] perf_event_ctx_lock_nested+0x15a/0x2d0 kernel/events/core.c:1240

stack backtrace:
CPU: 0 PID: 29431 Comm: syz-executor.4 Not tainted 4.14.142+ #0
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0xca/0x134 lib/dump_stack.c:53
 print_circular_bug.isra.0.cold+0x2dc/0x425 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+0x2f5f/0x4320 kernel/locking/lockdep.c:3487
 lock_acquire+0x12b/0x360 kernel/locking/lockdep.c:3991
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0xf7/0x13e0 kernel/locking/mutex.c:893
 swevent_hlist_get kernel/events/core.c:7896 [inline]
 perf_swevent_init+0x123/0x4f0 kernel/events/core.c:7956
 perf_try_init_event+0xe5/0x200 kernel/events/core.c:9347
 perf_init_event kernel/events/core.c:9385 [inline]
 perf_event_alloc.part.0+0xd13/0x1ff0 kernel/events/core.c:9645
 perf_event_alloc kernel/events/core.c:9998 [inline]
 SYSC_perf_event_open kernel/events/core.c:10105 [inline]
 SyS_perf_event_open+0x6eb/0x2560 kernel/events/core.c:9988
 do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x4598e9
RSP: 002b:00007fde92927c78 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00000000004598e9
RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 0000000020000200
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000004 R11: 0000000000000246 R12: 00007fde929286d4
R13: 00000000004c671d R14: 00000000004db7d8 R15: 00000000ffffffff
kauditd_printk_skb: 100 callbacks suppressed
audit: type=1400 audit(2000000389.790:5071): avc:  denied  { map } for  pid=29485 comm="syz-executor.4" path="/root/syzkaller-testdir120042307/syzkaller.8t7CV0/517/bus" dev="sda1" ino=17018 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000389.800:5072): avc:  denied  { map } for  pid=29492 comm="modprobe" path="/bin/kmod" dev="sda1" ino=1440 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000389.840:5073): avc:  denied  { map } for  pid=29494 comm="modprobe" path="/bin/kmod" dev="sda1" ino=1440 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000389.880:5074): avc:  denied  { map } for  pid=29495 comm="modprobe" path="/bin/kmod" dev="sda1" ino=1440 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
netlink: 32 bytes leftover after parsing attributes in process `syz-executor.3'.
audit: type=1400 audit(2000000389.880:5075): avc:  denied  { create } for  pid=29457 comm="syz-executor.2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_netfilter_socket permissive=1
ip6_tunnel: ip6tnl1 xmit: Local address not yet configured!
ip6_tunnel: . xmit: Local address not yet configured!
audit: type=1400 audit(2000000389.940:5076): avc:  denied  { map } for  pid=29500 comm="modprobe" path="/bin/kmod" dev="sda1" ino=1440 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000389.940:5077): avc:  denied  { map } for  pid=29500 comm="modprobe" path="/etc/ld.so.cache" dev="sda1" ino=2503 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000389.940:5079): avc:  denied  { map } for  pid=29500 comm="modprobe" path="/lib/x86_64-linux-gnu/libkmod.so.2.1.3" dev="sda1" ino=2811 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000389.940:5078): avc:  denied  { create } for  pid=29457 comm="syz-executor.2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
audit: type=1400 audit(2000000389.960:5080): avc:  denied  { write } for  pid=29457 comm="syz-executor.2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0 sclass=netlink_route_socket pig=29547 comm=syz-executor.2
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
ip6_tunnel: x xmit: Local address not yet configured!
kauditd_printk_skb: 105 callbacks suppressed
audit: type=1400 audit(2000000395.940:5186): avc:  denied  { map } for  pid=29718 comm="syz-executor.0" path="/root/syzkaller-testdir314781779/syzkaller.kIpWj2/17/bus" dev="sda1" ino=16738 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000396.110:5187): avc:  denied  { create } for  pid=29718 comm="syz-executor.0" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
audit: type=1400 audit(2000000396.110:5188): avc:  denied  { write } for  pid=29718 comm="syz-executor.0" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
audit: type=1400 audit(2000000396.140:5189): avc:  denied  { map } for  pid=29742 comm="modprobe" path="/bin/kmod" dev="sda1" ino=1440 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(2000000396.150:5190): avc:  denied  { read } for  pid=29718 comm="syz-executor.0" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
audit: type=1400 audit(2000000396.310:5191): avc:  denied  { map } for  pid=29748 comm="blkid" path="/sbin/blkid" dev="sda1" ino=16128 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1