syzbot


possible deadlock in io_write

Status: fixed on 2020/10/21 11:05
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+2f8fa4e860edc3066aba@syzkaller.appspotmail.com
Fix commit: fad8e0de4426 io_uring: fix potential ABBA deadlock in ->show_fdinfo()
First crash: 1477d, last: 1474d
Duplicate bugs (1)
duplicates (1):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
possible deadlock in io_uring_show_fdinfo fs 1 1475d 1475d 0/28 closed as dup on 2020/09/29 14:08
Discussions (3)
Title Replies (including bot) Last reply
[PATCH 5.8 000/124] 5.8.15-rc1 review 136 (136) 2020/10/14 18:31
[PATCH AUTOSEL 5.8 01/12] epoll: do not insert into poll queues until all sanity checks are done 13 (13) 2020/10/05 16:03
possible deadlock in io_write 1 (3) 2020/09/28 15:01

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.9.0-rc7-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/1430 is trying to acquire lock:
ffff888098732450 (sb_writers#4){.+.+}-{0:0}, at: io_write+0x50f/0x1230 fs/io_uring.c:3294

but task is already holding lock:
ffff88805c9c7428 (&ctx->uring_lock){+.+.}-{3:3}, at: __do_sys_io_uring_enter fs/io_uring.c:8348 [inline]
ffff88805c9c7428 (&ctx->uring_lock){+.+.}-{3:3}, at: __se_sys_io_uring_enter+0x19d/0x1300 fs/io_uring.c:8308

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ctx->uring_lock){+.+.}-{3:3}:
       lock_acquire+0x148/0x720 kernel/locking/lockdep.c:5029
       __mutex_lock_common+0x189/0x2fc0 kernel/locking/mutex.c:956
       __mutex_lock kernel/locking/mutex.c:1103 [inline]
       mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1118
       __io_uring_show_fdinfo fs/io_uring.c:8417 [inline]
       io_uring_show_fdinfo+0x6c/0x790 fs/io_uring.c:8460
       seq_show+0x567/0x620 fs/proc/fd.c:65
       seq_read+0x41a/0xce0 fs/seq_file.c:208
       do_loop_readv_writev fs/read_write.c:742 [inline]
       do_iter_read+0x438/0x620 fs/read_write.c:963
       vfs_readv fs/read_write.c:1081 [inline]
       do_preadv+0x17b/0x290 fs/read_write.c:1173
       do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9

-> #1 (&p->lock){+.+.}-{3:3}:
       lock_acquire+0x148/0x720 kernel/locking/lockdep.c:5029
       __mutex_lock_common+0x189/0x2fc0 kernel/locking/mutex.c:956
       __mutex_lock kernel/locking/mutex.c:1103 [inline]
       mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1118
       seq_read+0x60/0xce0 fs/seq_file.c:155
       do_loop_readv_writev fs/read_write.c:742 [inline]
       do_iter_read+0x438/0x620 fs/read_write.c:963
       vfs_readv+0xc2/0x120 fs/read_write.c:1081
       kernel_readv fs/splice.c:355 [inline]
       default_file_splice_read+0x579/0xa40 fs/splice.c:412
       do_splice_to fs/splice.c:871 [inline]
       splice_direct_to_actor+0x3de/0xb60 fs/splice.c:950
       do_splice_direct+0x201/0x340 fs/splice.c:1059
       do_sendfile+0x86d/0x1210 fs/read_write.c:1548
       __do_sys_sendfile64 fs/read_write.c:1609 [inline]
       __se_sys_sendfile64 fs/read_write.c:1595 [inline]
       __x64_sys_sendfile64+0x164/0x1a0 fs/read_write.c:1595
       do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9

-> #0 (sb_writers#4){.+.+}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:2496 [inline]
       check_prevs_add kernel/locking/lockdep.c:2601 [inline]
       validate_chain+0x1b0c/0x88a0 kernel/locking/lockdep.c:3218
       __lock_acquire+0x110b/0x2ae0 kernel/locking/lockdep.c:4441
       lock_acquire+0x148/0x720 kernel/locking/lockdep.c:5029
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write+0x14b/0x400 fs/super.c:1672
       io_write+0x50f/0x1230 fs/io_uring.c:3294
       io_issue_sqe+0x34fe/0xc1a0 fs/io_uring.c:5722
       __io_queue_sqe+0x297/0x1310 fs/io_uring.c:6178
       io_submit_sqe fs/io_uring.c:6327 [inline]
       io_submit_sqes+0x149f/0x2570 fs/io_uring.c:6521
       __do_sys_io_uring_enter fs/io_uring.c:8349 [inline]
       __se_sys_io_uring_enter+0x1af/0x1300 fs/io_uring.c:8308
       do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9

other info that might help us debug this:

Chain exists of:
  sb_writers#4 --> &p->lock --> &ctx->uring_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ctx->uring_lock);
                               lock(&p->lock);
                               lock(&ctx->uring_lock);
  lock(sb_writers#4);

 *** DEADLOCK ***

1 lock held by syz-executor.3/1430:
 #0: ffff88805c9c7428 (&ctx->uring_lock){+.+.}-{3:3}, at: __do_sys_io_uring_enter fs/io_uring.c:8348 [inline]
 #0: ffff88805c9c7428 (&ctx->uring_lock){+.+.}-{3:3}, at: __se_sys_io_uring_enter+0x19d/0x1300 fs/io_uring.c:8308

stack backtrace:
CPU: 1 PID: 1430 Comm: syz-executor.3 Not tainted 5.9.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1d6/0x29e lib/dump_stack.c:118
 print_circular_bug+0xc72/0xea0 kernel/locking/lockdep.c:1703
 check_noncircular+0x1fb/0x3a0 kernel/locking/lockdep.c:1827
 check_prev_add kernel/locking/lockdep.c:2496 [inline]
 check_prevs_add kernel/locking/lockdep.c:2601 [inline]
 validate_chain+0x1b0c/0x88a0 kernel/locking/lockdep.c:3218
 __lock_acquire+0x110b/0x2ae0 kernel/locking/lockdep.c:4441
 lock_acquire+0x148/0x720 kernel/locking/lockdep.c:5029
 percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
 __sb_start_write+0x14b/0x400 fs/super.c:1672
 io_write+0x50f/0x1230 fs/io_uring.c:3294
 io_issue_sqe+0x34fe/0xc1a0 fs/io_uring.c:5722
 __io_queue_sqe+0x297/0x1310 fs/io_uring.c:6178
 io_submit_sqe fs/io_uring.c:6327 [inline]
 io_submit_sqes+0x149f/0x2570 fs/io_uring.c:6521
 __do_sys_io_uring_enter fs/io_uring.c:8349 [inline]
 __se_sys_io_uring_enter+0x1af/0x1300 fs/io_uring.c:8308
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45dd99
Code: 0d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 db b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f7a85fb0c78 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa
RAX: ffffffffffffffda RBX: 00000000000082c0 RCX: 000000000045dd99
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000004
RBP: 000000000118bf78 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118bf2c
R13: 00007ffd88481bdf R14: 00007f7a85fb19c0 R15: 000000000118bf2c

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/09/30 13:31 upstream 02de58b24d2e 8516f6d3 .config console log report info ci-upstream-kasan-gce-smack-root
2020/09/27 07:22 upstream eeddbe6841cd 5dd8aee8 .config console log report info ci-upstream-kasan-gce-root
* Struck through repros no longer work on HEAD.