audit: type=1400 audit(1664777998.561:8): avc:  denied  { kernel } for  pid=3855 comm="syz-executor.7" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=perf_event permissive=1
------------[ cut here ]------------
======================================================
WARNING: possible circular locking dependency detected
6.0.0-rc7-next-20220930 #1 Not tainted
------------------------------------------------------
syz-executor.7/3857 is trying to acquire lock:
ffffffff853faab8 ((console_sem).lock){....}-{2:2}, at: down_trylock+0xe/0x70

but task is already holding lock:
ffff88800d845820 (&ctx->lock){....}-{2:2}, at: __perf_event_task_sched_out+0x53b/0x18d0

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ctx->lock){....}-{2:2}:
       _raw_spin_lock+0x2a/0x40
       __perf_event_task_sched_out+0x53b/0x18d0
       __schedule+0xedd/0x2470
       preempt_schedule_common+0x45/0xc0
       __cond_resched+0x17/0x30
       unmap_page_range+0xd89/0x2a10
       unmap_single_vma+0x190/0x380
       unmap_vmas+0x21e/0x370
       exit_mmap+0x154/0x680
       mmput+0xd1/0x390
       do_exit+0xa2e/0x27f0
       do_group_exit+0xd0/0x2a0
       get_signal+0x2195/0x22d0
       arch_do_signal_or_restart+0x89/0x1be0
       exit_to_user_mode_prepare+0x131/0x1a0
       syscall_exit_to_user_mode+0x19/0x40
       do_syscall_64+0x48/0x90
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #2 (&rq->__lock){-.-.}-{2:2}:
       _raw_spin_lock_nested+0x30/0x40
       raw_spin_rq_lock_nested+0x1e/0x30
       task_fork_fair+0x63/0x4d0
       sched_cgroup_fork+0x3d0/0x540
       copy_process+0x4183/0x6e20
       kernel_clone+0xe7/0x890
       user_mode_thread+0xad/0xf0
       rest_init+0x24/0x250
       arch_call_rest_init+0xf/0x14
       start_kernel+0x4c6/0x4eb
       secondary_startup_64_no_verify+0xe0/0xeb

-> #1 (&p->pi_lock){-.-.}-{2:2}:
       _raw_spin_lock_irqsave+0x39/0x60
       try_to_wake_up+0xab/0x1930
       up+0x75/0xb0
       __up_console_sem+0x6e/0x80
       console_unlock+0x46a/0x590
       do_con_write+0xc05/0x1d50
       con_write+0x21/0x40
       n_tty_write+0x4d4/0xfe0
       file_tty_write.constprop.0+0x455/0x8a0
       vfs_write+0x9c3/0xd90
       ksys_write+0x127/0x250
       do_syscall_64+0x3b/0x90
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 ((console_sem).lock){....}-{2:2}:
       __lock_acquire+0x2a02/0x5e70
       lock_acquire+0x1a2/0x530
       _raw_spin_lock_irqsave+0x39/0x60
       down_trylock+0xe/0x70
       __down_trylock_console_sem+0x3b/0xd0
       vprintk_emit+0x16b/0x560
       vprintk+0x84/0xa0
       _printk+0xba/0xf1
       report_bug.cold+0x72/0xab
       handle_bug+0x3c/0x70
       exc_invalid_op+0x14/0x50
       asm_exc_invalid_op+0x16/0x20
       group_sched_out.part.0+0x2c7/0x460
       ctx_sched_out+0x8f1/0xc10
       __perf_event_task_sched_out+0x6d0/0x18d0
       __schedule+0xedd/0x2470
       preempt_schedule_common+0x45/0xc0
       __cond_resched+0x17/0x30
       unmap_page_range+0xd89/0x2a10
       unmap_single_vma+0x190/0x380
       unmap_vmas+0x21e/0x370
       exit_mmap+0x154/0x680
       mmput+0xd1/0x390
       do_exit+0xa2e/0x27f0
       do_group_exit+0xd0/0x2a0
       get_signal+0x2195/0x22d0
       arch_do_signal_or_restart+0x89/0x1be0
       exit_to_user_mode_prepare+0x131/0x1a0
       syscall_exit_to_user_mode+0x19/0x40
       do_syscall_64+0x48/0x90
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  (console_sem).lock --> &rq->__lock --> &ctx->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ctx->lock);
                               lock(&rq->__lock);
                               lock(&ctx->lock);
  lock((console_sem).lock);

 *** DEADLOCK ***

3 locks held by syz-executor.7/3857:
 #0: ffff88801b837158 (&mm->mmap_lock#2){++++}-{3:3}, at: exit_mmap+0xe5/0x680
 #1: ffff88806ce37e98 (&rq->__lock){-.-.}-{2:2}, at: __schedule+0x1cf/0x2470
 #2: ffff88800d845820 (&ctx->lock){....}-{2:2}, at: __perf_event_task_sched_out+0x53b/0x18d0

stack backtrace:
CPU: 0 PID: 3857 Comm: syz-executor.7 Not tainted 6.0.0-rc7-next-20220930 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0x8b/0xb3
 check_noncircular+0x263/0x2e0
 __lock_acquire+0x2a02/0x5e70
 lock_acquire+0x1a2/0x530
 _raw_spin_lock_irqsave+0x39/0x60
 down_trylock+0xe/0x70
 __down_trylock_console_sem+0x3b/0xd0
 vprintk_emit+0x16b/0x560
 vprintk+0x84/0xa0
 _printk+0xba/0xf1
 report_bug.cold+0x72/0xab
 handle_bug+0x3c/0x70
 exc_invalid_op+0x14/0x50
 asm_exc_invalid_op+0x16/0x20
RIP: 0010:group_sched_out.part.0+0x2c7/0x460
Code: 5e 41 5f e9 8b ae ef ff e8 86 ae ef ff 65 8b 1d 0b 18 ac 7e 31 ff 89 de e8 26 ab ef ff 85 db 0f 84 8a 00 00 00 e8 69 ae ef ff <0f> 0b e9 a5 fe ff ff e8 5d ae ef ff 48 8d 7d 10 48 b8 00 00 00 00
RSP: 0018:ffff88801896f378 EFLAGS: 00010012
RAX: 0000000040000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff88801d278000 RSI: ffffffff81565dc7 RDI: 0000000000000005
RBP: ffff8880086605c8 R08: 0000000000000005 R09: 0000000000000001
R10: 0000000000000000 R11: ffffffff865b401b R12: ffff88800d845800
R13: ffff88806ce3d2c0 R14: ffffffff8547d000 R15: 0000000000000002
 ctx_sched_out+0x8f1/0xc10
 __perf_event_task_sched_out+0x6d0/0x18d0
 __schedule+0xedd/0x2470
 preempt_schedule_common+0x45/0xc0
 __cond_resched+0x17/0x30
 unmap_page_range+0xd89/0x2a10
 unmap_single_vma+0x190/0x380
 unmap_vmas+0x21e/0x370
 exit_mmap+0x154/0x680
 mmput+0xd1/0x390
 do_exit+0xa2e/0x27f0
 do_group_exit+0xd0/0x2a0
 get_signal+0x2195/0x22d0
 arch_do_signal_or_restart+0x89/0x1be0
 exit_to_user_mode_prepare+0x131/0x1a0
 syscall_exit_to_user_mode+0x19/0x40
 do_syscall_64+0x48/0x90
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc73da47b19
Code: Unable to access opcode bytes at 0x7fc73da47aef.
RSP: 002b:00007fc73afbd188 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: 0000000000000003 RBX: 00007fc73db5af60 RCX: 00007fc73da47b19
RDX: ffffffffffffffff RSI: 0000000000000000 RDI: 0000000020000080
RBP: 00007fc73daa1f6d R08: 0000000000000000 R09: 0000000000000000
R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff16c7f20f R14: 00007fc73afbd300 R15: 0000000000022000
 </TASK>
WARNING: CPU: 0 PID: 3857 at kernel/events/core.c:2309 group_sched_out.part.0+0x2c7/0x460
Modules linked in:
CPU: 0 PID: 3857 Comm: syz-executor.7 Not tainted 6.0.0-rc7-next-20220930 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
RIP: 0010:group_sched_out.part.0+0x2c7/0x460
Code: 5e 41 5f e9 8b ae ef ff e8 86 ae ef ff 65 8b 1d 0b 18 ac 7e 31 ff 89 de e8 26 ab ef ff 85 db 0f 84 8a 00 00 00 e8 69 ae ef ff <0f> 0b e9 a5 fe ff ff e8 5d ae ef ff 48 8d 7d 10 48 b8 00 00 00 00
RSP: 0018:ffff88801896f378 EFLAGS: 00010012
RAX: 0000000040000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff88801d278000 RSI: ffffffff81565dc7 RDI: 0000000000000005
RBP: ffff8880086605c8 R08: 0000000000000005 R09: 0000000000000001
R10: 0000000000000000 R11: ffffffff865b401b R12: ffff88800d845800
R13: ffff88806ce3d2c0 R14: ffffffff8547d000 R15: 0000000000000002
FS:  0000000000000000(0000) GS:ffff88806ce00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f81a89374a0 CR3: 0000000005226000 CR4: 0000000000350ef0
Call Trace:
 <TASK>
 ctx_sched_out+0x8f1/0xc10
 __perf_event_task_sched_out+0x6d0/0x18d0
 __schedule+0xedd/0x2470
 preempt_schedule_common+0x45/0xc0
 __cond_resched+0x17/0x30
 unmap_page_range+0xd89/0x2a10
 unmap_single_vma+0x190/0x380
 unmap_vmas+0x21e/0x370
 exit_mmap+0x154/0x680
 mmput+0xd1/0x390
 do_exit+0xa2e/0x27f0
 do_group_exit+0xd0/0x2a0
 get_signal+0x2195/0x22d0
 arch_do_signal_or_restart+0x89/0x1be0
 exit_to_user_mode_prepare+0x131/0x1a0
 syscall_exit_to_user_mode+0x19/0x40
 do_syscall_64+0x48/0x90
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc73da47b19
Code: Unable to access opcode bytes at 0x7fc73da47aef.
RSP: 002b:00007fc73afbd188 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: 0000000000000003 RBX: 00007fc73db5af60 RCX: 00007fc73da47b19
RDX: ffffffffffffffff RSI: 0000000000000000 RDI: 0000000020000080
RBP: 00007fc73daa1f6d R08: 0000000000000000 R09: 0000000000000000
R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff16c7f20f R14: 00007fc73afbd300 R15: 0000000000022000
 </TASK>
irq event stamp: 1226
hardirqs last  enabled at (1225): [<ffffffff84400d06>] asm_sysvec_apic_timer_interrupt+0x16/0x20
hardirqs last disabled at (1226): [<ffffffff8425caa5>] __schedule+0x1225/0x2470
softirqs last  enabled at (1224): [<ffffffff8116fa0b>] __irq_exit_rcu+0x11b/0x180
softirqs last disabled at (1217): [<ffffffff8116fa0b>] __irq_exit_rcu+0x11b/0x180
---[ end trace 0000000000000000 ]---
loop1: detected capacity change from 0 to 110
loop5: detected capacity change from 0 to 16383
capability: warning: `syz-executor.4' uses deprecated v2 capabilities in a way that may be insecure
capability: warning: `syz-executor.4' uses 32-bit capabilities (legacy support in use)