syzbot


possible deadlock in kernfs_fop_write_iter

Status: auto-obsoleted due to no activity on 2024/10/05 00:05
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+24386307cce6239b5f68@syzkaller.appspotmail.com
First crash: 108d, last: 78d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [kernfs?] possible deadlock in kernfs_fop_write_iter 0 (1) 2024/07/01 22:38

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.10.0-syzkaller-12708-g2f8c4f506285 #0 Not tainted
------------------------------------------------------
syz.2.1952/13649 is trying to acquire lock:
ffff88806523f888 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x1eb/0x500 fs/kernfs/file.c:325

but task is already holding lock:
ffff88806627ac68 (&pipe->mutex){+.+.}-{3:3}, at: iter_file_splice_write+0x335/0x14e0 fs/splice.c:687

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&pipe->mutex){+.+.}-{3:3}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
       pipe_write+0x1c9/0x1a40 fs/pipe.c:455
       __kernel_write_iter+0x47e/0x900 fs/read_write.c:523
       __kernel_write+0x120/0x180 fs/read_write.c:543
       autofs_write fs/autofs/waitq.c:57 [inline]
       autofs_notify_daemon+0x732/0xf80 fs/autofs/waitq.c:164
       autofs_wait+0x10b8/0x1b30 fs/autofs/waitq.c:426
       autofs_mount_wait+0x170/0x330 fs/autofs/root.c:255
       autofs_d_automount+0x555/0x710 fs/autofs/root.c:401
       follow_automount fs/namei.c:1394 [inline]
       __traverse_mounts+0x2ba/0x580 fs/namei.c:1439
       traverse_mounts fs/namei.c:1468 [inline]
       handle_mounts fs/namei.c:1571 [inline]
       step_into+0x5e5/0x1080 fs/namei.c:1877
       open_last_lookups fs/namei.c:3674 [inline]
       path_openat+0x184b/0x3470 fs/namei.c:3883
       do_filp_open+0x235/0x490 fs/namei.c:3913
       do_sys_openat2+0x13e/0x1d0 fs/open.c:1416
       do_sys_open fs/open.c:1431 [inline]
       __do_sys_open fs/open.c:1439 [inline]
       __se_sys_open fs/open.c:1435 [inline]
       __x64_sys_open+0x225/0x270 fs/open.c:1435
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&sbi->pipe_mutex){+.+.}-{3:3}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
       autofs_write fs/autofs/waitq.c:55 [inline]
       autofs_notify_daemon+0x71f/0xf80 fs/autofs/waitq.c:164
       autofs_wait+0x10b8/0x1b30 fs/autofs/waitq.c:426
       autofs_mount_wait+0x170/0x330 fs/autofs/root.c:255
       autofs_d_automount+0x555/0x710 fs/autofs/root.c:401
       follow_automount fs/namei.c:1394 [inline]
       __traverse_mounts+0x2ba/0x580 fs/namei.c:1439
       traverse_mounts fs/namei.c:1468 [inline]
       handle_mounts fs/namei.c:1571 [inline]
       step_into+0x5e5/0x1080 fs/namei.c:1877
       lookup_last fs/namei.c:2542 [inline]
       path_lookupat+0x16f/0x450 fs/namei.c:2566
       filename_lookup+0x256/0x610 fs/namei.c:2595
       kern_path+0x35/0x50 fs/namei.c:2703
       lookup_bdev+0xc5/0x290 block/bdev.c:1157
       resume_store+0x1a0/0x710 kernel/power/hibernate.c:1235
       kernfs_fop_write_iter+0x3a1/0x500 fs/kernfs/file.c:334
       iter_file_splice_write+0xbd7/0x14e0 fs/splice.c:743
       do_splice_from fs/splice.c:941 [inline]
       direct_splice_actor+0x11e/0x220 fs/splice.c:1164
       splice_direct_to_actor+0x58e/0xc90 fs/splice.c:1108
       do_splice_direct_actor fs/splice.c:1207 [inline]
       do_splice_direct+0x28c/0x3e0 fs/splice.c:1233
       do_sendfile+0x56d/0xe20 fs/read_write.c:1295
       __do_sys_sendfile64 fs/read_write.c:1362 [inline]
       __se_sys_sendfile64+0x17c/0x1e0 fs/read_write.c:1348
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&of->mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3133 [inline]
       check_prevs_add kernel/locking/lockdep.c:3252 [inline]
       validate_chain+0x18e0/0x5900 kernel/locking/lockdep.c:3868
       __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5142
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
       kernfs_fop_write_iter+0x1eb/0x500 fs/kernfs/file.c:325
       iter_file_splice_write+0xbd7/0x14e0 fs/splice.c:743
       do_splice_from fs/splice.c:941 [inline]
       do_splice+0xd77/0x1900 fs/splice.c:1354
       __do_splice fs/splice.c:1436 [inline]
       __do_sys_splice fs/splice.c:1652 [inline]
       __se_sys_splice+0x331/0x4a0 fs/splice.c:1634
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &of->mutex --> &sbi->pipe_mutex --> &pipe->mutex

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&pipe->mutex);
                               lock(&sbi->pipe_mutex);
                               lock(&pipe->mutex);
  lock(&of->mutex);

 *** DEADLOCK ***

2 locks held by syz.2.1952/13649:
 #0: ffff888030128420 (sb_writers#8){.+.+}-{0:0}, at: do_splice+0xcf0/0x1900 fs/splice.c:1353
 #1: ffff88806627ac68 (&pipe->mutex){+.+.}-{3:3}, at: iter_file_splice_write+0x335/0x14e0 fs/splice.c:687

stack backtrace:
CPU: 0 UID: 0 PID: 13649 Comm: syz.2.1952 Not tainted 6.10.0-syzkaller-12708-g2f8c4f506285 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2186
 check_prev_add kernel/locking/lockdep.c:3133 [inline]
 check_prevs_add kernel/locking/lockdep.c:3252 [inline]
 validate_chain+0x18e0/0x5900 kernel/locking/lockdep.c:3868
 __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5142
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
 __mutex_lock_common kernel/locking/mutex.c:608 [inline]
 __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
 kernfs_fop_write_iter+0x1eb/0x500 fs/kernfs/file.c:325
 iter_file_splice_write+0xbd7/0x14e0 fs/splice.c:743
 do_splice_from fs/splice.c:941 [inline]
 do_splice+0xd77/0x1900 fs/splice.c:1354
 __do_splice fs/splice.c:1436 [inline]
 __do_sys_splice fs/splice.c:1652 [inline]
 __se_sys_splice+0x331/0x4a0 fs/splice.c:1634
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f52bd377299
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f52be0ee048 EFLAGS: 00000246 ORIG_RAX: 0000000000000113
RAX: ffffffffffffffda RBX: 00007f52bd506208 RCX: 00007f52bd377299
RDX: 0000000000000006 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f52bd3e48e6 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000006e R14: 00007f52bd506208 R15: 00007ffc477c6048
 </TASK>

Crashes (14):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/27 00:04 upstream 2f8c4f506285 46eb10b7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/26 22:26 upstream 2f8c4f506285 3f86dfed .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/26 22:26 upstream 2f8c4f506285 3f86dfed .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/26 06:10 upstream 1722389b0d86 3f86dfed .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/23 20:30 upstream 28bbe4ea686a 708c10c4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/18 11:11 upstream b1bc554e009e 7403ec00 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/18 10:51 upstream b1bc554e009e 7403ec00 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/07/18 06:16 upstream b1bc554e009e 03114f55 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in kernfs_fop_write_iter
2024/06/27 22:27 upstream 66e55ff12e73 6ef39602 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream possible deadlock in kernfs_fop_write_iter
2024/07/21 06:59 upstream 2c9b3512402e b88348e9 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in kernfs_fop_write_iter
2024/07/21 06:59 upstream 2c9b3512402e b88348e9 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in kernfs_fop_write_iter
2024/07/21 06:59 upstream 2c9b3512402e b88348e9 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in kernfs_fop_write_iter
2024/07/25 04:33 linux-next 864b1099d16f b24754ac .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in kernfs_fop_write_iter
2024/07/24 15:30 linux-next 9ec6ec93f2c1 b24754ac .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in kernfs_fop_write_iter
* Struck through repros no longer work on HEAD.