syzbot


possible deadlock in try_to_wake_up (7)

Status: upstream: reported on 2024/11/21 07:32
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+e5ebce0ffa64d4f9e0cb@syzkaller.appspotmail.com
First crash: 131d, last: 57d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] possible deadlock in try_to_wake_up (7) 0 (1) 2024/11/21 07:32
Similar bugs (9)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in try_to_wake_up (2) origin:upstream C error 21 32d 323d 0/3 upstream: reported C repro on 2024/05/09 05:15
linux-6.1 possible deadlock in try_to_wake_up C done 1 366d 366d 3/3 fixed on 2024/04/29 07:11
linux-5.15 possible deadlock in try_to_wake_up origin:upstream C 40 1d19h 357d 0/3 upstream: reported C repro on 2024/04/05 17:03
upstream possible deadlock in try_to_wake_up (2) mm 1 922d 918d 0/28 auto-obsoleted due to no activity on 2023/01/16 12:10
upstream possible deadlock in try_to_wake_up (4) bpf net C error 19 312d 375d 25/28 fixed on 2024/05/22 23:36
upstream possible deadlock in try_to_wake_up (5) mm C 88 229d 302d 27/28 fixed on 2024/08/14 03:44
upstream possible deadlock in try_to_wake_up (3) net 103 527d 537d 0/28 auto-obsoleted due to no activity on 2023/11/27 02:05
upstream possible deadlock in try_to_wake_up mm 39 2265d 2297d 0/28 auto-closed as invalid on 2019/07/13 09:55
upstream possible deadlock in try_to_wake_up (6) kernel 1 212d 208d 0/28 auto-obsoleted due to no activity on 2024/10/27 05:34

Sample crash report:
audit: type=1400 audit(1738227502.746:298): avc:  denied  { setopt } for  pid=6274 comm="syz.2.101" laddr=127.0.0.1 lport=20002 scontext=root:sysadm_r:sysadm_t tcontext=root:sysadm_r:sysadm_t tclass=sctp_socket permissive=1
======================================================
WARNING: possible circular locking dependency detected
6.13.0-syzkaller-08265-g9c5968db9e62 #0 Not tainted
------------------------------------------------------
kauditd/29 is trying to acquire lock:
ffff88802875ae68 (&p->pi_lock){-.-.}-{2:2}, at: class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:551 [inline]
ffff88802875ae68 (&p->pi_lock){-.-.}-{2:2}, at: try_to_wake_up+0xb6/0x1490 kernel/sched/core.c:4213

but task is already holding lock:
ffffffff8e1abbd8 ((console_sem).lock){-.-.}-{2:2}, at: up+0x16/0xb0 kernel/locking/semaphore.c:187

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 ((console_sem).lock){-.-.}-{2:2}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
       down_trylock+0x12/0x70 kernel/locking/semaphore.c:139
       __down_trylock_console_sem+0x40/0x140 kernel/printk/printk.c:326
       console_trylock kernel/printk/printk.c:2852 [inline]
       console_trylock_spinning kernel/printk/printk.c:2009 [inline]
       vprintk_emit+0x3ec/0x6f0 kernel/printk/printk.c:2431
       _printk+0xc8/0x100 kernel/printk/printk.c:2457
       fail_dump lib/fault-inject.c:66 [inline]
       should_fail_ex+0x4df/0x650 lib/fault-inject.c:174
       strncpy_from_user+0x3b/0x2d0 lib/strncpy_from_user.c:118
       strncpy_from_user_nofault+0x7f/0x180 mm/maccess.c:193
       bpf_probe_read_user_str_common kernel/trace/bpf_trace.c:215 [inline]
       ____bpf_probe_read_compat_str kernel/trace/bpf_trace.c:310 [inline]
       bpf_probe_read_compat_str+0xf1/0x170 kernel/trace/bpf_trace.c:306
       0xffffffffa0001fc6
       bpf_dispatcher_nop_func include/linux/bpf.h:1290 [inline]
       __bpf_prog_run include/linux/filter.h:701 [inline]
       bpf_prog_run include/linux/filter.h:708 [inline]
       __bpf_trace_run kernel/trace/bpf_trace.c:2371 [inline]
       bpf_trace_run4+0x245/0x5a0 kernel/trace/bpf_trace.c:2414
       __bpf_trace_sched_switch+0x13e/0x190 include/trace/events/sched.h:222
       __do_trace_sched_switch include/trace/events/sched.h:222 [inline]
       trace_sched_switch include/trace/events/sched.h:222 [inline]
       __schedule+0x160c/0x5890 kernel/sched/core.c:6761
       preempt_schedule_notrace+0x62/0xe0 kernel/sched/core.c:7036
       preempt_schedule_notrace_thunk+0x1a/0x30 arch/x86/entry/thunk.S:13
       rcu_is_watching+0x8e/0xc0 kernel/rcu/tree.c:717
       trace_lock_acquire+0x14e/0x1f0 include/trace/events/lock.h:24
       lock_acquire+0x2f/0xb0 kernel/locking/lockdep.c:5822
       rcu_lock_acquire include/linux/rcupdate.h:337 [inline]
       rcu_read_lock include/linux/rcupdate.h:849 [inline]
       atomic_notifier_call_chain+0x40/0x1c0 kernel/notifier.c:222
       do_con_write+0x48f/0x7bb0 drivers/tty/vt/vt.c:3086
       con_write+0x23/0xb0 drivers/tty/vt/vt.c:3434
       process_output_block drivers/tty/n_tty.c:574 [inline]
       n_tty_write+0x419/0x1140 drivers/tty/n_tty.c:2389
       iterate_tty_write drivers/tty/tty_io.c:1015 [inline]
       file_tty_write.constprop.0+0x506/0x9a0 drivers/tty/tty_io.c:1090
       new_sync_write fs/read_write.c:586 [inline]
       vfs_write+0x5ae/0x1150 fs/read_write.c:679
       ksys_write+0x12b/0x250 fs/read_write.c:731
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&rq->__lock){-.-.}-{2:2}:
       _raw_spin_lock_nested+0x31/0x40 kernel/locking/spinlock.c:378
       raw_spin_rq_lock_nested+0x29/0x130 kernel/sched/core.c:598
       raw_spin_rq_lock kernel/sched/sched.h:1521 [inline]
       task_rq_lock+0xcf/0x3b0 kernel/sched/core.c:700
       cgroup_move_task+0x82/0x250 kernel/sched/psi.c:1161
       css_set_move_task+0x288/0x5f0 kernel/cgroup/cgroup.c:898
       cgroup_post_fork+0x1c6/0x910 kernel/cgroup/cgroup.c:6691
       copy_process+0x5034/0x8d60 kernel/fork.c:2618
       kernel_clone+0xfd/0x960 kernel/fork.c:2804
       user_mode_thread+0xb4/0xf0 kernel/fork.c:2882
       rest_init+0x23/0x2b0 init/main.c:708
       start_kernel+0x3e9/0x4d0 init/main.c:1099
       x86_64_start_reservations+0x18/0x30 arch/x86/kernel/head64.c:515
       x86_64_start_kernel+0xb2/0xc0 arch/x86/kernel/head64.c:496
       common_startup_64+0x13e/0x148

-> #0 (&p->pi_lock){-.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3163 [inline]
       check_prevs_add kernel/locking/lockdep.c:3282 [inline]
       validate_chain kernel/locking/lockdep.c:3906 [inline]
       __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5228
       lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5851
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
       class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:551 [inline]
       try_to_wake_up+0xb6/0x1490 kernel/sched/core.c:4213
       up+0x79/0xb0 kernel/locking/semaphore.c:191
       __up_console_sem+0x85/0xe0 kernel/printk/printk.c:343
       __console_unlock kernel/printk/printk.c:2869 [inline]
       __console_flush_and_unlock kernel/printk/printk.c:3271 [inline]
       console_unlock+0x1dc/0x210 kernel/printk/printk.c:3309
       vprintk_emit+0x424/0x6f0 kernel/printk/printk.c:2432
       _printk+0xc8/0x100 kernel/printk/printk.c:2457
       kauditd_printk_skb kernel/audit.c:546 [inline]
       kauditd_hold_skb+0x205/0x250 kernel/audit.c:581
       kauditd_send_queue+0x236/0x290 kernel/audit.c:766
       kauditd_thread+0x611/0xa60 kernel/audit.c:890
       kthread+0x3af/0x750 kernel/kthread.c:464
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

other info that might help us debug this:

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

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

1 lock held by kauditd/29:
 #0: ffffffff8e1abbd8 ((console_sem).lock){-.-.}-{2:2}, at: up+0x16/0xb0 kernel/locking/semaphore.c:187

stack backtrace:
CPU: 1 UID: 0 PID: 29 Comm: kauditd Not tainted 6.13.0-syzkaller-08265-g9c5968db9e62 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x490/0x760 kernel/locking/lockdep.c:2076
 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2208
 check_prev_add kernel/locking/lockdep.c:3163 [inline]
 check_prevs_add kernel/locking/lockdep.c:3282 [inline]
 validate_chain kernel/locking/lockdep.c:3906 [inline]
 __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5228
 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5851
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
 class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:551 [inline]
 try_to_wake_up+0xb6/0x1490 kernel/sched/core.c:4213
 up+0x79/0xb0 kernel/locking/semaphore.c:191
 __up_console_sem+0x85/0xe0 kernel/printk/printk.c:343
 __console_unlock kernel/printk/printk.c:2869 [inline]
 __console_flush_and_unlock kernel/printk/printk.c:3271 [inline]
 console_unlock+0x1dc/0x210 kernel/printk/printk.c:3309
 vprintk_emit+0x424/0x6f0 kernel/printk/printk.c:2432
 _printk+0xc8/0x100 kernel/printk/printk.c:2457
 kauditd_printk_skb kernel/audit.c:546 [inline]
 kauditd_hold_skb+0x205/0x250 kernel/audit.c:581
 kauditd_send_queue+0x236/0x290 kernel/audit.c:766
 kauditd_thread+0x611/0xa60 kernel/audit.c:890
 kthread+0x3af/0x750 kernel/kthread.c:464
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>
audit: type=1400 audit(1738227503.056:299): avc:  denied  { rename } for  pid=5172 comm="syslogd" name="messages" dev="tmpfs" ino=3 scontext=system_u:system_r:syslogd_t tcontext=system_u:object_r:tmpfs_t tclass=file permissive=1
audit: type=1400 audit(1738227503.056:300): avc:  denied  { unlink } for  pid=5172 comm="syslogd" name="messages.0" dev="tmpfs" ino=2 scontext=system_u:system_r:syslogd_t tcontext=system_u:object_r:tmpfs_t tclass=file permissive=1

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/30 08:58 upstream 9c5968db9e62 afe4eff5 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root possible deadlock in try_to_wake_up
2024/11/17 07:24 upstream 4a5df3796467 cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in try_to_wake_up
* Struck through repros no longer work on HEAD.