[v5.15] possible deadlock in n_tty_flush_buffer

0 views
Skip to first unread message

syzbot

unread,
Aug 4, 2026, 3:36:45 PM (yesterday) Aug 4
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6e2fd6534337 Linux 5.15.213
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1465acc6580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f161cbc9aef65db0
dashboard link: https://syzkaller.appspot.com/bug?extid=22b59b2ab69a00d4b29f
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d7b46606b13d/disk-6e2fd653.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/da120fdeb081/vmlinux-6e2fd653.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3c2643457e3f/bzImage-6e2fd653.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+22b59b...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/0:7/4473 is trying to acquire lock:
ffff88801bef42e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_flush_buffer+0x2c/0x1e0 drivers/tty/n_tty.c:369

but task is already holding lock:
ffff88807e6cf0b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x78/0x370 drivers/tty/tty_buffer.c:230

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&buf->lock){+.+.}-{3:3}:
__mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
tty_buffer_flush+0x78/0x370 drivers/tty/tty_buffer.c:230
tty_ldisc_flush+0x6a/0xc0 drivers/tty/tty_ldisc.c:400
__do_SAK+0x260/0x5f0 drivers/tty/tty_io.c:3051
vc_SAK+0x74/0x210 drivers/tty/vt/vt_ioctl.c:993
process_one_work+0x867/0xff0 kernel/workqueue.c:2310
worker_thread+0xad7/0x12a0 kernel/workqueue.c:2457
kthread+0x42e/0x520 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

-> #2 (console_lock){+.+.}-{0:0}:
console_lock+0x47/0x70 kernel/printk/printk.c:2557
uart_configure_port drivers/tty/serial/serial_core.c:2425 [inline]
uart_add_one_port+0x826/0x1d10 drivers/tty/serial/serial_core.c:2980
serial8250_register_8250_port+0x137f/0x1a80 drivers/tty/serial/8250/8250_core.c:1094
serial_pnp_probe+0x569/0x740 drivers/tty/serial/8250/8250_pnp.c:482
pnp_device_probe+0x2bc/0x470 drivers/pnp/driver.c:111
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x276/0xc70 drivers/base/dd.c:595
__driver_probe_device+0x1f5/0x390 drivers/base/dd.c:775
driver_probe_device+0x4f/0x420 drivers/base/dd.c:805
__driver_attach+0x45d/0x660 drivers/base/dd.c:1184
bus_for_each_dev+0x182/0x1f0 drivers/base/bus.c:303
bus_add_driver+0x324/0x5d0 drivers/base/bus.c:620
driver_register+0x32d/0x430 drivers/base/driver.c:240
serial8250_init+0x96/0x170 drivers/tty/serial/8250/8250_core.c:1190
do_one_initcall+0x272/0x730 init/main.c:1315
do_initcall_level+0x13d/0x1f0 init/main.c:1388
do_initcalls+0x4b/0x90 init/main.c:1404
kernel_init_freeable+0x3d5/0x560 init/main.c:1628
kernel_init+0x19/0x1b0 init/main.c:1519
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

-> #1 (&port->mutex){+.+.}-{3:3}:
__mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
uart_set_termios+0x80/0x900 drivers/tty/serial/serial_core.c:1522
tty_set_termios+0xc73/0x1770 drivers/tty/tty_ioctl.c:358
set_termios+0x6d3/0x8a0 drivers/tty/tty_ioctl.c:458
tty_mode_ioctl+0x686/0x890 drivers/tty/tty_ioctl.c:-1
tty_ioctl+0x8e3/0xc30 drivers/tty/tty_io.c:2819
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&tty->termios_rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3788 [inline]
__lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
down_write+0x38/0x60 kernel/locking/rwsem.c:1551
n_tty_flush_buffer+0x2c/0x1e0 drivers/tty/n_tty.c:369
tty_buffer_flush+0x2e4/0x370 drivers/tty/tty_buffer.c:241
tty_ldisc_flush+0x6a/0xc0 drivers/tty/tty_ldisc.c:400
__do_SAK+0x260/0x5f0 drivers/tty/tty_io.c:3051
vc_SAK+0x74/0x210 drivers/tty/vt/vt_ioctl.c:993
process_one_work+0x867/0xff0 kernel/workqueue.c:2310
worker_thread+0xad7/0x12a0 kernel/workqueue.c:2457
kthread+0x42e/0x520 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

other info that might help us debug this:

Chain exists of:
&tty->termios_rwsem --> console_lock --> &buf->lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&buf->lock);
lock(console_lock);
lock(&buf->lock);
lock(&tty->termios_rwsem);

*** DEADLOCK ***

5 locks held by kworker/0:7/4473:
#0: ffff888016c70938 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x75c/0xff0 kernel/workqueue.c:-1
#1: ffffc90004b1fd00 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work+0x79e/0xff0 kernel/workqueue.c:2285
#2: ffffffff8c313aa0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x24/0x210 drivers/tty/vt/vt_ioctl.c:983
#3: ffff88801bef4098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref drivers/tty/tty_ldisc.c:273 [inline]
#3: ffff88801bef4098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x1c/0xc0 drivers/tty/tty_ldisc.c:398
#4: ffff88807e6cf0b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x78/0x370 drivers/tty/tty_buffer.c:230

stack backtrace:
CPU: 0 PID: 4473 Comm: kworker/0:7 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Workqueue: events vc_SAK
Call Trace:
<TASK>
dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
check_noncircular+0x296/0x330 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3788 [inline]
__lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
down_write+0x38/0x60 kernel/locking/rwsem.c:1551
n_tty_flush_buffer+0x2c/0x1e0 drivers/tty/n_tty.c:369
tty_buffer_flush+0x2e4/0x370 drivers/tty/tty_buffer.c:241
tty_ldisc_flush+0x6a/0xc0 drivers/tty/tty_ldisc.c:400
__do_SAK+0x260/0x5f0 drivers/tty/tty_io.c:3051
vc_SAK+0x74/0x210 drivers/tty/vt/vt_ioctl.c:993
process_one_work+0x867/0xff0 kernel/workqueue.c:2310
worker_thread+0xad7/0x12a0 kernel/workqueue.c:2457
kthread+0x42e/0x520 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Aug 4, 2026, 4:24:26 PM (yesterday) Aug 4
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: fb28aa725e05 Linux 6.1.180
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17e14bb9580000
kernel config: https://syzkaller.appspot.com/x/.config?x=872c04466179833f
dashboard link: https://syzkaller.appspot.com/bug?extid=49b9711a74417d5c50a2
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d420eb944682/disk-fb28aa72.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/affae450ab23/vmlinux-fb28aa72.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b9e6919ed519/Image-fb28aa72.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+49b971...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/0:4/4377 is trying to acquire lock:
ffff0000dcf752e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_flush_buffer+0x30/0x1e4 drivers/tty/n_tty.c:370

but task is already holding lock:
ffff0000c08480b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x80/0x3fc drivers/tty/tty_buffer.c:230

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&buf->lock){+.+.}-{3:3}:
__mutex_lock_common+0x1a0/0x1f3c kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
tty_buffer_flush+0x80/0x3fc drivers/tty/tty_buffer.c:230
tty_ldisc_flush+0x70/0xcc drivers/tty/tty_ldisc.c:389
__do_SAK+0x224/0x5b8 drivers/tty/tty_io.c:3011
vc_SAK+0x78/0x1d4 drivers/tty/vt/vt_ioctl.c:995
process_one_work+0x7e4/0x13bc kernel/workqueue.c:2292
worker_thread+0x8cc/0xfe8 kernel/workqueue.c:2439
kthread+0x254/0x2e0 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850

-> #2 (console_lock){+.+.}-{0:0}:
console_lock+0x1bc/0x230 kernel/printk/printk.c:2629
register_console+0x404/0x8c4 kernel/printk/printk.c:3236
uart_configure_port drivers/tty/serial/serial_core.c:2616 [inline]
uart_add_one_port+0x10d0/0x1974 drivers/tty/serial/serial_core.c:3135
pl011_register_port+0x190/0x430 drivers/tty/serial/amba-pl011.c:2776
sbsa_uart_probe+0x420/0x548 drivers/tty/serial/amba-pl011.c:2935
platform_probe+0x148/0x1c8 drivers/base/platform.c:1400
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x3a0/0xac4 drivers/base/dd.c:638
__driver_probe_device+0x1c8/0x368 drivers/base/dd.c:804
driver_probe_device+0x78/0x324 drivers/base/dd.c:834
__device_attach_driver+0x28c/0x4c0 drivers/base/dd.c:962
bus_for_each_drv+0x154/0x1e4 drivers/base/bus.c:429
__device_attach+0x2a4/0x3d8 drivers/base/dd.c:1034
device_initial_probe+0x24/0x34 drivers/base/dd.c:1083
bus_probe_device+0xbc/0x1c4 drivers/base/bus.c:489
device_add+0x93c/0xe4c drivers/base/core.c:3712
platform_device_add+0x3f8/0x6f4 drivers/base/platform.c:717
platform_device_register_full+0x4fc/0x610 drivers/base/platform.c:844
acpi_create_platform_device+0x464/0x594 drivers/acpi/acpi_platform.c:152
acpi_default_enumeration+0x6c/0xdc drivers/acpi/scan.c:2118
acpi_bus_attach+0x880/0xa9c drivers/acpi/scan.c:2229
acpi_dev_for_one_check+0xa0/0xb4 drivers/acpi/bus.c:1090
device_for_each_child+0xf0/0x180 drivers/base/core.c:4043
acpi_dev_for_each_child+0x98/0xe4 drivers/acpi/bus.c:1102
acpi_bus_attach+0x284/0xa9c drivers/acpi/scan.c:2234
acpi_dev_for_one_check+0xa0/0xb4 drivers/acpi/bus.c:1090
device_for_each_child+0xf0/0x180 drivers/base/core.c:4043
acpi_dev_for_each_child+0x98/0xe4 drivers/acpi/bus.c:1102
acpi_bus_attach+0x284/0xa9c drivers/acpi/scan.c:2234
acpi_bus_scan+0xbc/0x1bc drivers/acpi/scan.c:2445
acpi_scan_init+0x1bc/0x5dc drivers/acpi/scan.c:2615
acpi_init+0x16c/0x220 drivers/acpi/bus.c:1411
do_one_initcall+0x278/0x9f0 init/main.c:1309
do_initcall_level+0x158/0x214 init/main.c:1382
do_initcalls+0x58/0xac init/main.c:1398
do_basic_setup+0x8c/0xa0 init/main.c:1417
kernel_init_freeable+0x35c/0x4f0 init/main.c:1637
kernel_init+0x24/0x1d8 init/main.c:1525
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850

-> #1 (&port->mutex){+.+.}-{3:3}:
__mutex_lock_common+0x1a0/0x1f3c kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
uart_set_termios+0x74/0x718 drivers/tty/serial/serial_core.c:1651
tty_set_termios+0x8d4/0x1150 drivers/tty/tty_ioctl.c:363
set_termios+0x484/0x610 drivers/tty/tty_ioctl.c:537
tty_mode_ioctl+0x510/0x790 drivers/tty/tty_ioctl.c:822
n_tty_ioctl_helper+0xb0/0x2d8 drivers/tty/tty_ioctl.c:1001
n_tty_ioctl+0x190/0x42c drivers/tty/n_tty.c:2510
tty_ioctl+0x920/0xd88 drivers/tty/tty_io.c:2785
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:856
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x290 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x13c/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x5c/0x134 arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x128 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #0 (&tty->termios_rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain kernel/locking/lockdep.c:3830 [inline]
__lock_acquire+0x2808/0x6634 kernel/locking/lockdep.c:5063
lock_acquire+0x20c/0x638 kernel/locking/lockdep.c:5676
down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
n_tty_flush_buffer+0x30/0x1e4 drivers/tty/n_tty.c:370
tty_buffer_flush+0x2e8/0x3fc drivers/tty/tty_buffer.c:242
tty_ldisc_flush+0x70/0xcc drivers/tty/tty_ldisc.c:389
__do_SAK+0x224/0x5b8 drivers/tty/tty_io.c:3011
vc_SAK+0x78/0x1d4 drivers/tty/vt/vt_ioctl.c:995
process_one_work+0x7e4/0x13bc kernel/workqueue.c:2292
worker_thread+0x8cc/0xfe8 kernel/workqueue.c:2439
kthread+0x254/0x2e0 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850

other info that might help us debug this:

Chain exists of:
&tty->termios_rwsem --> console_lock --> &buf->lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&buf->lock);
lock(console_lock);
lock(&buf->lock);
lock(&tty->termios_rwsem);

*** DEADLOCK ***

5 locks held by kworker/0:4/4377:
#0: ffff0000c0020938 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x69c/0x13bc kernel/workqueue.c:-1
#1: ffff8000212a7c40 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work+0x6e8/0x13bc kernel/workqueue.c:2267
#2: ffff80001554d1a0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x30/0x1d4 drivers/tty/vt/vt_ioctl.c:985
#3: ffff0000dcf75098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref drivers/tty/tty_ldisc.c:264 [inline]
#3: ffff0000dcf75098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x24/0xcc drivers/tty/tty_ldisc.c:387
#4: ffff0000c08480b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x80/0x3fc drivers/tty/tty_buffer.c:230

stack backtrace:
CPU: 0 PID: 4377 Comm: kworker/0:4 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/02/2026
Workqueue: events vc_SAK
Call trace:
dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack+0x30/0x40 lib/dump_stack.c:88
dump_stack_lvl+0xf4/0x15c lib/dump_stack.c:106
dump_stack+0x1c/0x5c lib/dump_stack.c:113
print_circular_bug+0x148/0x1b0 kernel/locking/lockdep.c:2048
check_noncircular+0x264/0x2f8 kernel/locking/lockdep.c:2170
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain kernel/locking/lockdep.c:3830 [inline]
__lock_acquire+0x2808/0x6634 kernel/locking/lockdep.c:5063
lock_acquire+0x20c/0x638 kernel/locking/lockdep.c:5676
down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
n_tty_flush_buffer+0x30/0x1e4 drivers/tty/n_tty.c:370
tty_buffer_flush+0x2e8/0x3fc drivers/tty/tty_buffer.c:242
tty_ldisc_flush+0x70/0xcc drivers/tty/tty_ldisc.c:389
__do_SAK+0x224/0x5b8 drivers/tty/tty_io.c:3011
vc_SAK+0x78/0x1d4 drivers/tty/vt/vt_ioctl.c:995
process_one_work+0x7e4/0x13bc kernel/workqueue.c:2292
worker_thread+0x8cc/0xfe8 kernel/workqueue.c:2439
kthread+0x254/0x2e0 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850
tty tty1: SAK: killed process 4693 (syz.9.52): by fd#3
tty tty1: SAK: killed process 4694 (syz.9.52): by fd#3
(NULL device *): Create Association LS failed: Association Allocation Failed

syzbot

unread,
Aug 4, 2026, 5:19:35 PM (yesterday) Aug 4
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: aa0e49877a2e Linux 6.6.148
git tree: linux-6.6.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12c15bb9580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f0bc3d90c30838b5
dashboard link: https://syzkaller.appspot.com/bug?extid=b2cc229a584bebf6d9cb
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f83b390cfc1f/disk-aa0e4987.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1d4bdb338edd/vmlinux-aa0e4987.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3f57c1d51ee3/bzImage-aa0e4987.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b2cc22...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/1:3/2178 is trying to acquire lock:
ffff8880589b12e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_flush_buffer+0x30/0x230 drivers/tty/n_tty.c:363

but task is already holding lock:
ffff8880186510b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x79/0x3e0 drivers/tty/tty_buffer.c:229

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&buf->lock){+.+.}-{3:3}:
__mutex_lock_common kernel/locking/mutex.c:603 [inline]
__mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747
tty_buffer_flush+0x79/0x3e0 drivers/tty/tty_buffer.c:229
tty_ldisc_flush+0x6b/0xc0 drivers/tty/tty_ldisc.c:388
__do_SAK+0x25b/0x680 drivers/tty/tty_io.c:3014
vc_SAK+0x78/0x220 drivers/tty/vt/vt_ioctl.c:995
process_one_work kernel/workqueue.c:2657 [inline]
process_scheduled_works+0xa60/0x1600 kernel/workqueue.c:2734
worker_thread+0xa5e/0xfe0 kernel/workqueue.c:2815
kthread+0x2fa/0x390 kernel/kthread.c:388
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

-> #2 (console_lock){+.+.}-{0:0}:
console_lock+0x164/0x1b0 kernel/printk/printk.c:2686
uart_configure_port drivers/tty/serial/serial_core.c:2632 [inline]
serial_core_add_one_port drivers/tty/serial/serial_core.c:3199 [inline]
serial_core_register_port+0xbee/0x20b0 drivers/tty/serial/serial_core.c:3422
serial8250_register_8250_port+0x15fd/0x1f40 drivers/tty/serial/8250/8250_core.c:1142
serial_pnp_probe+0x577/0x750 drivers/tty/serial/8250/8250_pnp.c:478
pnp_device_probe+0x305/0x4b0 drivers/pnp/driver.c:111
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x247/0xae0 drivers/base/dd.c:717
__driver_probe_device+0x1f5/0x390 drivers/base/dd.c:879
driver_probe_device+0x4f/0x420 drivers/base/dd.c:909
__driver_attach+0x444/0x6d0 drivers/base/dd.c:1295
bus_for_each_dev+0x235/0x2b0 drivers/base/bus.c:370
bus_add_driver+0x340/0x630 drivers/base/bus.c:723
driver_register+0x23a/0x310 drivers/base/driver.c:246
serial8250_init+0x9a/0x170 drivers/tty/serial/8250/8250_core.c:1243
do_one_initcall+0x242/0x790 init/main.c:1210
do_initcall_level+0x13d/0x1f0 init/main.c:1272
do_initcalls+0x69/0xd0 init/main.c:1288
kernel_init_freeable+0x3d9/0x560 init/main.c:1525
kernel_init+0x1d/0x1c0 init/main.c:1415
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

-> #1 (&port->mutex){+.+.}-{3:3}:
__mutex_lock_common kernel/locking/mutex.c:603 [inline]
__mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747
uart_set_termios+0x84/0x900 drivers/tty/serial/serial_core.c:1703
tty_set_termios+0xcb1/0x17e0 drivers/tty/tty_ioctl.c:354
set_termios+0x52b/0x6c0 drivers/tty/tty_ioctl.c:528
tty_mode_ioctl+0x49f/0x7b0 drivers/tty/tty_ioctl.c:-1
tty_ioctl+0x9b5/0xdc0 drivers/tty/tty_io.c:2788
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:871 [inline]
__se_sys_ioctl+0xfd/0x170 fs/ioctl.c:857
do_syscall_x64 arch/x86/entry/common.c:46 [inline]
do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&tty->termios_rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
down_write+0x97/0x200 kernel/locking/rwsem.c:1573
n_tty_flush_buffer+0x30/0x230 drivers/tty/n_tty.c:363
tty_buffer_flush+0x31e/0x3e0 drivers/tty/tty_buffer.c:241
tty_ldisc_flush+0x6b/0xc0 drivers/tty/tty_ldisc.c:388
__do_SAK+0x25b/0x680 drivers/tty/tty_io.c:3014
vc_SAK+0x78/0x220 drivers/tty/vt/vt_ioctl.c:995
process_one_work kernel/workqueue.c:2657 [inline]
process_scheduled_works+0xa60/0x1600 kernel/workqueue.c:2734
worker_thread+0xa5e/0xfe0 kernel/workqueue.c:2815
kthread+0x2fa/0x390 kernel/kthread.c:388
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

other info that might help us debug this:

Chain exists of:
&tty->termios_rwsem --> console_lock --> &buf->lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&buf->lock);
lock(console_lock);
lock(&buf->lock);
lock(&tty->termios_rwsem);

*** DEADLOCK ***

5 locks held by kworker/1:3/2178:
#0: ffff888017c70938 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:2632 [inline]
#0: ffff888017c70938 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x975/0x1600 kernel/workqueue.c:2734
#1: ffffc900053e7d00 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:2632 [inline]
#1: ffffc900053e7d00 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_scheduled_works+0x975/0x1600 kernel/workqueue.c:2734
#2: ffffffff8d126180 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x28/0x220 drivers/tty/vt/vt_ioctl.c:985
#3: ffff8880589b10a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref drivers/tty/tty_ldisc.c:263 [inline]
#3: ffff8880589b10a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x20/0xc0 drivers/tty/tty_ldisc.c:386
#4: ffff8880186510b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x79/0x3e0 drivers/tty/tty_buffer.c:229

stack backtrace:
CPU: 1 PID: 2178 Comm: kworker/1:3 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Workqueue: events vc_SAK
Call Trace:
<TASK>
dump_stack_lvl+0x18c/0x250 lib/dump_stack.c:106
check_noncircular+0x2fc/0x400 kernel/locking/lockdep.c:2187
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
down_write+0x97/0x200 kernel/locking/rwsem.c:1573
n_tty_flush_buffer+0x30/0x230 drivers/tty/n_tty.c:363
tty_buffer_flush+0x31e/0x3e0 drivers/tty/tty_buffer.c:241
tty_ldisc_flush+0x6b/0xc0 drivers/tty/tty_ldisc.c:388
__do_SAK+0x25b/0x680 drivers/tty/tty_io.c:3014
vc_SAK+0x78/0x220 drivers/tty/vt/vt_ioctl.c:995
process_one_work kernel/workqueue.c:2657 [inline]
process_scheduled_works+0xa60/0x1600 kernel/workqueue.c:2734
worker_thread+0xa5e/0xfe0 kernel/workqueue.c:2815
kthread+0x2fa/0x390 kernel/kthread.c:388
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293
</TASK>

syzbot

unread,
11:44 AM (6 hours ago) 11:44 AM
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: fb28aa725e05 Linux 6.1.180
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12180132580000
kernel config: https://syzkaller.appspot.com/x/.config?x=872c04466179833f
dashboard link: https://syzkaller.appspot.com/bug?extid=49b9711a74417d5c50a2
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10c63bb9580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d62bb9580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d420eb944682/disk-fb28aa72.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/affae450ab23/vmlinux-fb28aa72.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b9e6919ed519/Image-fb28aa72.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+49b971...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/1:20/4438 is trying to acquire lock:
ffff0000d36ce2e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_flush_buffer+0x30/0x1e4 drivers/tty/n_tty.c:370
5 locks held by kworker/1:20/4438:
#0: ffff0000c0020938 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x69c/0x13bc kernel/workqueue.c:-1
#1: ffff8000214d7c40 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work+0x6e8/0x13bc kernel/workqueue.c:2267
#2: ffff80001554d1a0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x30/0x1d4 drivers/tty/vt/vt_ioctl.c:985
#3: ffff0000d36ce098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref drivers/tty/tty_ldisc.c:264 [inline]
#3: ffff0000d36ce098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x24/0xcc drivers/tty/tty_ldisc.c:387
#4: ffff0000c08480b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x80/0x3fc drivers/tty/tty_buffer.c:230

stack backtrace:
CPU: 1 PID: 4438 Comm: kworker/1:20 Not tainted syzkaller #0
tty tty1: SAK: killed process 4571 (syz.1.70): by fd#3
tty tty1: SAK: killed process 4575 (syz.1.74): by fd#3
tty tty1: SAK: killed process 4614 (syz.0.113): by fd#3
tty tty1: SAK: killed process 4658 (syz.3.138): by fd#3
tty tty1: SAK: killed process 4664 (syz.3.144): by fd#3
tty tty1: SAK: killed process 4665 (syz.4.21): by fd#3
tty tty1: SAK: killed process 4666 (syz.2.19): by fd#3


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Reply all
Reply to author
Forward
0 new messages