syzbot


possible deadlock in iter_file_splice_write (2)

Status: closed as dup on 2021/07/28 14:57
Subsystems: overlayfs
[Documentation on labels]
Reported-by: syzbot+4bdbcaa79e8ee36fe6af@syzkaller.appspotmail.com
First crash: 1215d, last: 1215d
Cause bisection: introduced by (bisect log) :
commit 82a763e61e2b601309d696d4fa514c77d64ee1be
Author: Miklos Szeredi <mszeredi@redhat.com>
Date: Mon Dec 14 14:26:14 2020 +0000

  ovl: simplify file splice

Crash: possible deadlock in iter_file_splice_write (log)
Repro: C syz .config
  
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
possible deadlock in pipe_lock (5) overlayfs C done 5 1215d 1215d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] possible deadlock in iter_file_splice_write (2) 1 (3) 2021/07/28 20:57
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in iter_file_splice_write (3) overlayfs 24 210d 252d 0/28 closed as dup on 2024/03/14 09:27
upstream possible deadlock in iter_file_splice_write overlayfs 1 1541d 1537d 0/28 auto-closed as invalid on 2020/12/30 21:45
upstream possible deadlock in iter_file_splice_write (4) overlayfs 19 6d16h 169d 0/28 closed as dup on 2024/06/05 11:05
linux-5.15 possible deadlock in iter_file_splice_write 1 27d 27d 0/3 upstream: reported on 2024/10/24 14:50
Last patch testing requests (1)
Created Duration User Patch Repo Result
2021/07/28 14:32 45m miklos@szeredi.hu git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git overlayfs-next OK

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.14.0-rc2-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor919/8626 is trying to acquire lock:
ffff8880141ed068 (&pipe->mutex/1){+.+.}-{3:3}, at: iter_file_splice_write+0x257/0xf30 fs/splice.c:635

but task is already holding lock:
ffff888029aac460 (sb_writers#5){.+.+}-{0:0}, at: __do_splice fs/splice.c:1144 [inline]
ffff888029aac460 (sb_writers#5){.+.+}-{0:0}, at: __do_sys_splice fs/splice.c:1350 [inline]
ffff888029aac460 (sb_writers#5){.+.+}-{0:0}, at: __se_sys_splice+0x32c/0x430 fs/splice.c:1332

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sb_writers#5){.+.+}-{0:0}:
       lock_acquire+0x182/0x4a0 kernel/locking/lockdep.c:5625
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1763 [inline]
       sb_start_write include/linux/fs.h:1833 [inline]
       file_start_write+0xc7/0x230 include/linux/fs.h:3040
       ovl_write_iter+0x81d/0xdb0 fs/overlayfs/file.c:357
       do_iter_readv_writev+0x566/0x770 include/linux/fs.h:2108
       do_iter_write+0x16c/0x5f0 fs/read_write.c:866
       iter_file_splice_write+0x7c1/0xf30 fs/splice.c:689
       do_splice_from fs/splice.c:767 [inline]
       do_splice+0xe8e/0x17e0 fs/splice.c:1079
       __do_splice fs/splice.c:1144 [inline]
       __do_sys_splice fs/splice.c:1350 [inline]
       __se_sys_splice+0x32c/0x430 fs/splice.c:1332
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

-> #1 (&ovl_i_mutex_key[depth]){+.+.}-{3:3}:
       lock_acquire+0x182/0x4a0 kernel/locking/lockdep.c:5625
       down_write+0x97/0x170 kernel/locking/rwsem.c:1406
       inode_lock include/linux/fs.h:774 [inline]
       ovl_write_iter+0x132/0xdb0 fs/overlayfs/file.c:341
       do_iter_readv_writev+0x566/0x770 include/linux/fs.h:2108
       do_iter_write+0x16c/0x5f0 fs/read_write.c:866
       iter_file_splice_write+0x7c1/0xf30 fs/splice.c:689
       do_splice_from fs/splice.c:767 [inline]
       do_splice+0xe8e/0x17e0 fs/splice.c:1079
       __do_splice fs/splice.c:1144 [inline]
       __do_sys_splice fs/splice.c:1350 [inline]
       __se_sys_splice+0x32c/0x430 fs/splice.c:1332
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

-> #0 (&pipe->mutex/1){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3051 [inline]
       check_prevs_add+0x4f9/0x5b30 kernel/locking/lockdep.c:3174
       validate_chain kernel/locking/lockdep.c:3789 [inline]
       __lock_acquire+0x4476/0x6100 kernel/locking/lockdep.c:5015
       lock_acquire+0x182/0x4a0 kernel/locking/lockdep.c:5625
       __mutex_lock_common+0x1ad/0x3770 kernel/locking/mutex.c:959
       __mutex_lock kernel/locking/mutex.c:1104 [inline]
       mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1119
       iter_file_splice_write+0x257/0xf30 fs/splice.c:635
       do_splice_from fs/splice.c:767 [inline]
       do_splice+0xe8e/0x17e0 fs/splice.c:1079
       __do_splice fs/splice.c:1144 [inline]
       __do_sys_splice fs/splice.c:1350 [inline]
       __se_sys_splice+0x32c/0x430 fs/splice.c:1332
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

other info that might help us debug this:

Chain exists of:
  &pipe->mutex/1 --> &ovl_i_mutex_key[depth] --> sb_writers#5

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sb_writers#5);
                               lock(&ovl_i_mutex_key[depth]);
                               lock(sb_writers#5);
  lock(&pipe->mutex/1);

 *** DEADLOCK ***

1 lock held by syz-executor919/8626:
 #0: ffff888029aac460 (sb_writers#5){.+.+}-{0:0}, at: __do_splice fs/splice.c:1144 [inline]
 #0: ffff888029aac460 (sb_writers#5){.+.+}-{0:0}, at: __do_sys_splice fs/splice.c:1350 [inline]
 #0: ffff888029aac460 (sb_writers#5){.+.+}-{0:0}, at: __se_sys_splice+0x32c/0x430 fs/splice.c:1332

stack backtrace:
CPU: 0 PID: 8626 Comm: syz-executor919 Not tainted 5.14.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1ae/0x29f lib/dump_stack.c:105
 print_circular_bug+0xb17/0xdc0 kernel/locking/lockdep.c:2009
 check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2131
 check_prev_add kernel/locking/lockdep.c:3051 [inline]
 check_prevs_add+0x4f9/0x5b30 kernel/locking/lockdep.c:3174
 validate_chain kernel/locking/lockdep.c:3789 [inline]
 __lock_acquire+0x4476/0x6100 kernel/locking/lockdep.c:5015
 lock_acquire+0x182/0x4a0 kernel/locking/lockdep.c:5625
 __mutex_lock_common+0x1ad/0x3770 kernel/locking/mutex.c:959
 __mutex_lock kernel/locking/mutex.c:1104 [inline]
 mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1119
 iter_file_splice_write+0x257/0xf30 fs/splice.c:635
 do_splice_from fs/splice.c:767 [inline]
 do_splice+0xe8e/0x17e0 fs/splice.c:1079
 __do_splice fs/splice.c:1144 [inline]
 __do_sys_splice fs/splice.c:1350 [inline]
 __se_sys_splice+0x32c/0x430 fs/splice.c:1332
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x4461b9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7b06be32e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000113
RAX: ffffffffffffffda RBX: 00000000004cb4f0 RCX: 00000000004461b9
RDX: 0000000000000005 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 000000000049b06c R08: 000000000004ffdc R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 3d72696472657070
R13: 0079616c7265766f R14: 69662f7375622f2e R15: 00000000004cb4f8

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/07/24 16:04 upstream f0fddcec6b62 4d1b57d4 .config console log report syz C ci-upstream-kasan-gce-smack-root possible deadlock in iter_file_splice_write
2021/07/24 14:14 upstream f0fddcec6b62 4d1b57d4 .config console log report info ci-upstream-kasan-gce-smack-root possible deadlock in iter_file_splice_write
* Struck through repros no longer work on HEAD.