syzbot


possible deadlock in ovl_write_iter

Status: closed as dup on 2019/02/12 15:47
Subsystems: overlayfs
[Documentation on labels]
Reported-by: syzbot+695726bc473f9c36a4b6@syzkaller.appspotmail.com
First crash: 2095d, last: 1870d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
possible deadlock in pipe_lock (2) overlayfs 3 1887d 1956d
Discussions (2)
Title Replies (including bot) Last reply
[PATCH]i[RESEND] kernel/acct.c: fix locking order when switching acct files 3 (3) 2019/02/26 14:22
possible deadlock in ovl_write_iter 7 (9) 2018/11/27 16:13
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in ovl_write_iter syz done 84 1680d 1890d 1/1 fixed on 2019/12/19 13:28
linux-4.19 possible deadlock in ovl_write_iter (3) C error 132 471d 1404d 0/1 upstream: reported C repro on 2020/08/16 01:29
linux-4.19 possible deadlock in ovl_write_iter (2) syz done 2 1564d 1564d 1/1 fixed on 2020/04/09 01:05

Sample crash report:
Process accounting resumed
======================================================
WARNING: possible circular locking dependency detected
5.1.0-rc5+ #75 Not tainted
------------------------------------------------------
syz-executor847/8140 is trying to acquire lock:
000000001a8f685a (&ovl_i_mutex_key[depth]){+.+.}, at: inode_lock include/linux/fs.h:772 [inline]
000000001a8f685a (&ovl_i_mutex_key[depth]){+.+.}, at: ovl_write_iter+0x148/0xc20 fs/overlayfs/file.c:231

but task is already holding lock:
00000000fc0dd0e2 (&acct->lock#2){+.+.}, at: acct_pin_kill+0x27/0x100 kernel/acct.c:173

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&acct->lock#2){+.+.}:
       lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4211
       __mutex_lock_common kernel/locking/mutex.c:925 [inline]
       __mutex_lock+0xf7/0x1310 kernel/locking/mutex.c:1072
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087
       acct_pin_kill+0x27/0x100 kernel/acct.c:173
       pin_kill+0x18f/0x860 fs/fs_pin.c:50
       acct_on+0x574/0x790 kernel/acct.c:254
       __do_sys_acct kernel/acct.c:286 [inline]
       __se_sys_acct kernel/acct.c:273 [inline]
       __x64_sys_acct+0xae/0x200 kernel/acct.c:273
       do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #1 (sb_writers#4){.+.+}:
       lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4211
       percpu_down_read include/linux/percpu-rwsem.h:36 [inline]
       __sb_start_write+0x20b/0x360 fs/super.c:1613
       sb_start_write include/linux/fs.h:1621 [inline]
       mnt_want_write+0x3f/0xc0 fs/namespace.c:358
       ovl_want_write+0x76/0xa0 fs/overlayfs/util.c:24
       ovl_setattr+0xdd/0x8b0 fs/overlayfs/inode.c:30
       notify_change+0xad9/0xfb0 fs/attr.c:334
       do_truncate+0x158/0x220 fs/open.c:63
       handle_truncate fs/namei.c:3006 [inline]
       do_last fs/namei.c:3422 [inline]
       path_openat+0x2d6a/0x46e0 fs/namei.c:3533
       do_filp_open+0x1a1/0x280 fs/namei.c:3563
       do_sys_open+0x3fe/0x5d0 fs/open.c:1069
       ksys_open include/linux/syscalls.h:1373 [inline]
       __do_sys_creat fs/open.c:1127 [inline]
       __se_sys_creat fs/open.c:1125 [inline]
       __x64_sys_creat+0x61/0x80 fs/open.c:1125
       do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&ovl_i_mutex_key[depth]){+.+.}:
       check_prevs_add kernel/locking/lockdep.c:2333 [inline]
       validate_chain kernel/locking/lockdep.c:2714 [inline]
       __lock_acquire+0x239c/0x3fb0 kernel/locking/lockdep.c:3701
       lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4211
       down_write+0x38/0x90 kernel/locking/rwsem.c:70
       inode_lock include/linux/fs.h:772 [inline]
       ovl_write_iter+0x148/0xc20 fs/overlayfs/file.c:231
       call_write_iter include/linux/fs.h:1866 [inline]
       new_sync_write+0x4c7/0x760 fs/read_write.c:474
       __vfs_write+0xe4/0x110 fs/read_write.c:487
       __kernel_write+0x110/0x3b0 fs/read_write.c:506
       do_acct_process+0xd37/0x1150 kernel/acct.c:520
       acct_pin_kill+0x2f/0x100 kernel/acct.c:174
       pin_kill+0x18f/0x860 fs/fs_pin.c:50
       acct_on+0x574/0x790 kernel/acct.c:254
       __do_sys_acct kernel/acct.c:286 [inline]
       __se_sys_acct kernel/acct.c:273 [inline]
       __x64_sys_acct+0xae/0x200 kernel/acct.c:273
       do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

Chain exists of:
  &ovl_i_mutex_key[depth] --> sb_writers#4 --> &acct->lock#2

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&acct->lock#2);
                               lock(sb_writers#4);
                               lock(&acct->lock#2);
  lock(&ovl_i_mutex_key[depth]);

 *** DEADLOCK ***

4 locks held by syz-executor847/8140:
 #0: 00000000a843d0f5 (acct_on_mutex){+.+.}, at: __do_sys_acct kernel/acct.c:285 [inline]
 #0: 00000000a843d0f5 (acct_on_mutex){+.+.}, at: __se_sys_acct kernel/acct.c:273 [inline]
 #0: 00000000a843d0f5 (acct_on_mutex){+.+.}, at: __x64_sys_acct+0xa6/0x200 kernel/acct.c:273
 #1: 0000000026daab77 (sb_writers#9){.+.+}, at: sb_start_write include/linux/fs.h:1621 [inline]
 #1: 0000000026daab77 (sb_writers#9){.+.+}, at: mnt_want_write+0x3f/0xc0 fs/namespace.c:358
 #2: 00000000fc0dd0e2 (&acct->lock#2){+.+.}, at: acct_pin_kill+0x27/0x100 kernel/acct.c:173
 #3: 0000000026daab77 (sb_writers#9){.+.+}, at: file_start_write_trylock include/linux/fs.h:2832 [inline]
 #3: 0000000026daab77 (sb_writers#9){.+.+}, at: do_acct_process+0xf37/0x1150 kernel/acct.c:517

stack backtrace:
CPU: 1 PID: 8140 Comm: syz-executor847 Not tainted 5.1.0-rc5+ #75
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+0x172/0x1f0 lib/dump_stack.c:113
 print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1571
 check_prev_add.constprop.0+0xf11/0x23c0 kernel/locking/lockdep.c:2220
 check_prevs_add kernel/locking/lockdep.c:2333 [inline]
 validate_chain kernel/locking/lockdep.c:2714 [inline]
 __lock_acquire+0x239c/0x3fb0 kernel/locking/lockdep.c:3701
 lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4211
 down_write+0x38/0x90 kernel/locking/rwsem.c:70
 inode_lock include/linux/fs.h:772 [inline]
 ovl_write_iter+0x148/0xc20 fs/overlayfs/file.c:231
 call_write_iter include/linux/fs.h:1866 [inline]
 new_sync_write+0x4c7/0x760 fs/read_write.c:474
 __vfs_write+0xe4/0x110 fs/read_write.c:487
 __kernel_write+0x110/0x3b0 fs/read_write.c:506
 do_acct_process+0xd37/0x1150 kernel/acct.c:520
 acct_pin_kill+0x2f/0x100 kernel/acct.c:174
 pin_kill+0x18f/0x860 fs/fs_pin.c:50
 acct_on+0x574/0x790 kernel/acct.c:254
 __do_sys_acct kernel/acct.c:286 [inline]
 __se_sys_acct kernel/acct.c:273 [inline]
 __x64_sys_acct+0xae/0x200 kernel/acct.c:273
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4473e9
Code: e8 cc e7 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 3b 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f7d6df64d98 EFLAGS: 00000246 ORIG_RAX: 00000000000000a3
RAX: ffffffffffffffda RBX: 00000000006e29e8 RCX: 00000000004473e9
RDX: 00000000004473e9 RSI: 00000000004473e9 RDI: 0000000020000040
RBP: 00000000006e29e0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006e29ec
R13: 69647265776f6c2c R14: 30656c69662f2e3d R15: 7269647265707075
Process accounting resumed

Crashes (222):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/04/19 22:14 upstream 3ecafda911f4 b0e8efcb .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/04/18 14:38 upstream e53f31bffe1d b0e8efcb .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/08 20:37 upstream 74e96711e337 fa6c7b70 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/08 20:34 upstream 74e96711e337 fa6c7b70 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/08 20:07 upstream 74e96711e337 fa6c7b70 .config console log report syz C ci-upstream-kasan-gce-root
2018/11/27 19:36 upstream ef78e5ec9214 4b6d14f2 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2018/11/27 16:22 upstream ef78e5ec9214 4b6d14f2 .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/11/27 07:05 upstream 6f8b52ba442c ac912200 .config console log report syz C ci-upstream-kasan-gce-root
2019/02/09 00:33 linux-next a46228f6598a fa6c7b70 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/11/28 04:17 linux-next 442b8cea2477 4b6d14f2 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/05/07 21:21 upstream 8ff468c29e9a a7383bfa .config console log report ci-upstream-kasan-gce-root
2019/05/03 20:03 upstream a4ccb5f9dc6c d28f4ce5 .config console log report ci-upstream-kasan-gce-root
2019/05/03 13:55 upstream ea9866793d1e 1bfa09b9 .config console log report ci-upstream-kasan-gce-selinux-root
2019/05/03 08:08 upstream ea9866793d1e 1bfa09b9 .config console log report ci-upstream-kasan-gce-root
2019/05/02 19:13 upstream b7a5b22b0547 e9039493 .config console log report ci-upstream-kasan-gce-root
2019/05/02 13:36 upstream 459e3a21535a 7516d9fa .config console log report ci-upstream-kasan-gce-smack-root
2019/05/01 19:46 upstream 459e3a21535a 7516d9fa .config console log report ci-upstream-kasan-gce-root
2019/05/01 18:08 upstream f2bc9c908dfe 7516d9fa .config console log report ci-upstream-kasan-gce-root
2019/04/30 19:20 upstream bf3bd966dfd7 618456b4 .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/30 17:58 upstream 83a50840e72a 618456b4 .config console log report ci-upstream-kasan-gce-root
2019/04/30 06:51 upstream 83a50840e72a 20f16bef .config console log report ci-upstream-kasan-gce-root
2019/04/30 03:55 upstream 80871482fd5c b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/29 22:04 upstream 80871482fd5c b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/29 20:52 upstream 37624b58542f b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/29 18:10 upstream 37624b58542f b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/29 15:42 upstream 37624b58542f b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/29 14:57 upstream 37624b58542f b617407b .config console log report ci-upstream-kasan-gce-smack-root
2019/04/29 08:56 upstream 37624b58542f b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/29 07:33 upstream 9520b5324b0e b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/29 03:03 upstream 9520b5324b0e b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/28 18:34 upstream 9520b5324b0e b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/28 16:06 upstream 037904a22bf8 b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/28 13:37 upstream 037904a22bf8 b617407b .config console log report ci-upstream-kasan-gce-smack-root
2019/04/28 09:59 upstream 037904a22bf8 b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/28 00:20 upstream 037904a22bf8 b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/27 23:19 upstream baf76f0c58ae b617407b .config console log report ci-upstream-kasan-gce-smack-root
2019/04/27 20:55 upstream baf76f0c58ae b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/27 19:10 upstream baf76f0c58ae b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/27 18:02 upstream baf76f0c58ae b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/27 07:09 upstream baf76f0c58ae b617407b .config console log report ci-upstream-kasan-gce-smack-root
2019/04/27 04:10 upstream d0473f978e61 b617407b .config console log report ci-upstream-kasan-gce-smack-root
2019/04/26 23:41 upstream d0473f978e61 b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/26 19:57 upstream d0473f978e61 b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/26 16:54 upstream 8113a85f8720 b617407b .config console log report ci-upstream-kasan-gce-root
2019/04/26 09:42 upstream 8113a85f8720 b617407b .config console log report ci-upstream-kasan-gce-smack-root
2019/04/26 07:02 upstream 8113a85f8720 b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/26 04:50 upstream 8113a85f8720 b617407b .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/25 16:46 upstream f6f3e747454f f46aabc8 .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/25 15:24 upstream cd8dead0c394 f46aabc8 .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/24 18:05 upstream ba25b50d582f 8e3c52b1 .config console log report ci-upstream-kasan-gce-smack-root
2019/04/24 11:19 upstream ba25b50d582f 8e3c52b1 .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/24 06:52 upstream 7142eaa58b49 4d3d6a50 .config console log report ci-upstream-kasan-gce-smack-root
2019/04/23 22:04 upstream 7142eaa58b49 4d3d6a50 .config console log report ci-upstream-kasan-gce-root
2019/04/23 16:23 upstream 085b7755808a 53199d6e .config console log report ci-upstream-kasan-gce-selinux-root
2018/09/26 15:34 upstream a38523185b40 455b6354 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/23 13:42 linux-next e382d91f5f80 3361bde5 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/25 04:10 linux-next dad486875956 0e7547d7 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.