syzbot


possible deadlock in lru_add_drain_all

Status: public: reported C repro on 2019/04/11 00:00
Reported-by: syzbot+6d1c2cc3e56d9909c9dc@syzkaller.appspotmail.com
First crash: 2244d, last: 1818d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in lru_add_drain_all mm 1300 2535d 2584d 4/28 fixed on 2018/02/14 17:52

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
4.14.90+ #29 Not tainted
------------------------------------------------------
syz-executor554/5513 is trying to acquire lock:
 (cpu_hotplug_lock.rw_sem){++++}, at: [<ffffffffb74635da>] get_online_cpus include/linux/cpu.h:138 [inline]
 (cpu_hotplug_lock.rw_sem){++++}, at: [<ffffffffb74635da>] lru_add_drain_all+0xa/0x20 mm/swap.c:729

but task is already holding lock:
 (&sb->s_type->i_mutex_key#10){+.+.}, at: [<ffffffffb74844b2>] inode_lock include/linux/fs.h:715 [inline]
 (&sb->s_type->i_mutex_key#10){+.+.}, at: [<ffffffffb74844b2>] shmem_add_seals+0x132/0x1230 mm/shmem.c:2829

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&sb->s_type->i_mutex_key#10){+.+.}:
       down_write+0x34/0x90 kernel/locking/rwsem.c:54
       inode_lock include/linux/fs.h:715 [inline]
       shmem_fallocate+0x149/0xb20 mm/shmem.c:2902
       ashmem_shrink_scan+0x1b6/0x4e0 drivers/staging/android/ashmem.c:453
       ashmem_ioctl+0x2cc/0xe20 drivers/staging/android/ashmem.c:795
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x1a0/0x1030 fs/ioctl.c:684
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x7e/0xb0 fs/ioctl.c:692
       do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #4 (ashmem_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xf5/0x1480 kernel/locking/mutex.c:893
       ashmem_mmap+0x4c/0x430 drivers/staging/android/ashmem.c:369
       call_mmap include/linux/fs.h:1789 [inline]
       mmap_region+0x836/0xfb0 mm/mmap.c:1731
       do_mmap+0x551/0xb80 mm/mmap.c:1509
       do_mmap_pgoff include/linux/mm.h:2167 [inline]
       vm_mmap_pgoff+0x180/0x1d0 mm/util.c:333
       SYSC_mmap_pgoff mm/mmap.c:1559 [inline]
       SyS_mmap_pgoff+0xf8/0x1a0 mm/mmap.c:1517
       do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #3 (&mm->mmap_sem){++++}:
       __might_fault+0x137/0x1b0 mm/memory.c:4555
       _copy_from_user+0x27/0x100 lib/usercopy.c:10
       copy_from_user include/linux/uaccess.h:147 [inline]
       perf_event_period kernel/events/core.c:4753 [inline]
       _perf_ioctl kernel/events/core.c:4808 [inline]
       perf_ioctl+0x6ef/0x1bb0 kernel/events/core.c:4875
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x1a0/0x1030 fs/ioctl.c:684
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x7e/0xb0 fs/ioctl.c:692
       do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #2 (&cpuctx_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xf5/0x1480 kernel/locking/mutex.c:893
       perf_event_init_cpu+0xab/0x150 kernel/events/core.c:11213
       perf_event_init+0x295/0x2d4 kernel/events/core.c:11260
       start_kernel+0x444/0x73f init/main.c:621
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:240

-> #1 (pmus_lock){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xf5/0x1480 kernel/locking/mutex.c:893
       perf_event_init_cpu+0x2c/0x150 kernel/events/core.c:11207
       cpuhp_invoke_callback+0x1b5/0x1960 kernel/cpu.c:184
       cpuhp_up_callbacks kernel/cpu.c:574 [inline]
       _cpu_up+0x22c/0x520 kernel/cpu.c:1134
       do_cpu_up+0x13f/0x180 kernel/cpu.c:1169
       smp_init+0x137/0x14e kernel/smp.c:578
       kernel_init_freeable+0x189/0x3a5 init/main.c:1068
       kernel_init+0xc/0x157 init/main.c:1000
       ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

-> #0 (cpu_hotplug_lock.rw_sem){++++}:
       lock_acquire+0x10f/0x380 kernel/locking/lockdep.c:3991
       percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline]
       percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
       cpus_read_lock+0x39/0xb0 kernel/cpu.c:295
       get_online_cpus include/linux/cpu.h:138 [inline]
       lru_add_drain_all+0xa/0x20 mm/swap.c:729
       shmem_wait_for_pins mm/shmem.c:2732 [inline]
       shmem_add_seals+0x4db/0x1230 mm/shmem.c:2841
       shmem_fcntl+0xea/0x120 mm/shmem.c:2876
       do_fcntl+0x966/0xea0 fs/fcntl.c:421
       SYSC_fcntl fs/fcntl.c:463 [inline]
       SyS_fcntl+0xc7/0x100 fs/fcntl.c:448
       do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

other info that might help us debug this:

Chain exists of:
  cpu_hotplug_lock.rw_sem --> ashmem_mutex --> &sb->s_type->i_mutex_key#10

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sb->s_type->i_mutex_key#10);
                               lock(ashmem_mutex);
                               lock(&sb->s_type->i_mutex_key#10);
  lock(cpu_hotplug_lock.rw_sem);

 *** DEADLOCK ***

1 lock held by syz-executor554/5513:
 #0:  (&sb->s_type->i_mutex_key#10){+.+.}, at: [<ffffffffb74844b2>] inode_lock include/linux/fs.h:715 [inline]
 #0:  (&sb->s_type->i_mutex_key#10){+.+.}, at: [<ffffffffb74844b2>] shmem_add_seals+0x132/0x1230 mm/shmem.c:2829

stack backtrace:
CPU: 1 PID: 5513 Comm: syz-executor554 Not tainted 4.14.90+ #29
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0xb9/0x11b lib/dump_stack.c:53
 print_circular_bug.isra.18.cold.43+0x2d3/0x40c kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1901 [inline]
 check_prevs_add kernel/locking/lockdep.c:2018 [inline]
 validate_chain kernel/locking/lockdep.c:2460 [inline]
 __lock_acquire+0x2ff9/0x4320 kernel/locking/lockdep.c:3487
 lock_acquire+0x10f/0x380 kernel/locking/lockdep.c:3991
 percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline]
 percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
 cpus_read_lock+0x39/0xb0 kernel/cpu.c:295
 get_online_cpus include/linux/cpu.h:138 [inline]
 lru_add_drain_all+0xa/0x20 mm/swap.c:729
 shmem_wait_for_pins mm/shmem.c:2732 [inline]
 shmem_add_seals+0x4db/0x1230 mm/shmem.c:2841
 shmem_fcntl+0xea/0x120 mm/shmem.c:2876
 do_fcntl+0x966/0xea0 fs/fcntl.c:421
 SYSC_fcntl fs/fcntl.c:463 [inline]
 SyS_fcntl+0xc7/0x100 fs/fcntl.c:448
 do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x444519
RSP: 002b:00007ffd727c48a8 EFLAGS: 00000207 ORIG_RAX: 0000000000000048
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000444519
RDX: 000000000000000d RSI: 0000000000000409 RDI: 0000000000000003
RBP: 0000000000000000 R08: 00000000000000ba R09: 00000000000000ba
R10: 00000000000000ba R11: 0000000000000207 R12: 00000000000000ba
R13: 000000000000f091 R14: 0000000000000000 R15: 0000000000000000

Crashes (38):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/12/23 23:39 android-4.14 815e34f802d8 e3bd7ab8 .config console log report syz C ci-android-414-kasan-gce-root
2018/12/20 10:41 android-4.14 2eaa69bd84cf 02e69052 .config console log report syz C ci-android-414-kasan-gce-root
2018/11/13 21:26 android-4.14 97c308ca4091 5f5f6d14 .config console log report syz C ci-android-414-kasan-gce-root
2018/11/10 13:17 android-4.14 87485dbe777b f9815aaf .config console log report syz C ci-android-414-kasan-gce-root
2018/10/08 21:47 android-4.14 d33692e8014d 8b311eaf .config console log report syz C ci-android-414-kasan-gce-root
2018/10/02 18:31 android-4.14 e6fa8a2046e5 a316a2af .config console log report syz C ci-android-414-kasan-gce-root
2019/12/02 18:05 android-4.14 13855a652bd5 f879db37 .config console log report ci-android-414-kasan-gce-root
2019/11/25 16:47 android-4.14 f9b4ab5c8e99 371caf77 .config console log report ci-android-414-kasan-gce-root
2019/11/23 08:41 android-4.14 437a2a739c5f 598ca6c8 .config console log report ci-android-414-kasan-gce-root
2019/10/13 05:25 android-4.14 1d75f58e4e19 426631dd .config console log report ci-android-414-kasan-gce-root
2019/10/12 18:49 android-4.14 1d75f58e4e19 426631dd .config console log report ci-android-414-kasan-gce-root
2019/10/12 07:12 android-4.14 5faab626bf1f 426631dd .config console log report ci-android-414-kasan-gce-root
2019/06/29 22:06 android-4.14 71162e6530df 7509bf36 .config console log report ci-android-414-kasan-gce-root
2019/06/27 16:41 android-4.14 93c338c2e7ba 7509bf36 .config console log report ci-android-414-kasan-gce-root
2019/05/02 16:39 android-4.14 c680586c4fb7 7516d9fa .config console log report ci-android-414-kasan-gce-root
2019/04/29 21:22 android-4.14 ffa22221c473 b617407b .config console log report ci-android-414-kasan-gce-root
2019/02/26 21:40 android-4.14 38aeba63ed0d a36ecd98 .config console log report ci-android-414-kasan-gce-root
2019/02/17 00:31 android-4.14 4a739e3530cc f42dee6d .config console log report ci-android-414-kasan-gce-root
2019/01/31 02:34 android-4.14 63d1657d00e0 aa432daf .config console log report ci-android-414-kasan-gce-root
2019/01/05 20:58 android-4.14 3c207c880674 53be0a37 .config console log report ci-android-414-kasan-gce-root
2018/12/21 14:43 android-4.14 815e34f802d8 588075e6 .config console log report ci-android-414-kasan-gce-root
2018/12/18 10:21 android-4.14 a6424a3d08fb def91db3 .config console log report ci-android-414-kasan-gce-root
2018/11/25 14:35 android-4.14 ea91d158d712 3d3ec907 .config console log report ci-android-414-kasan-gce-root
2018/11/15 17:03 android-4.14 4e76528bd48d 5f5f6d14 .config console log report ci-android-414-kasan-gce-root
2018/11/09 13:58 android-4.14 2de3f80d5ba2 8fd01d3a .config console log report ci-android-414-kasan-gce-root
2018/11/08 17:01 android-4.14 d4e5dea08bbf e85d2a61 .config console log report ci-android-414-kasan-gce-root
2018/11/05 22:35 android-4.14 d4e5dea08bbf 8bd6bd63 .config console log report ci-android-414-kasan-gce-root
2018/11/05 15:27 android-4.14 d4e5dea08bbf 8bd6bd63 .config console log report ci-android-414-kasan-gce-root
2018/11/05 02:22 android-4.14 12064f3a794e 8bd6bd63 .config console log report ci-android-414-kasan-gce-root
2018/10/29 17:14 android-4.14 4ed22187defd 7df9db2e .config console log report ci-android-414-kasan-gce-root
2018/10/29 03:36 android-4.14 4ed22187defd 9ca2afa1 .config console log report ci-android-414-kasan-gce-root
2018/10/22 06:50 android-4.14 c556d1ffe528 ecb386fe .config console log report ci-android-414-kasan-gce-root
2018/10/21 15:34 android-4.14 c556d1ffe528 ecb386fe .config console log report ci-android-414-kasan-gce-root
2018/10/21 00:55 android-4.14 c556d1ffe528 ecb386fe .config console log report ci-android-414-kasan-gce-root
2018/10/19 05:50 android-4.14 0ff0788d6a66 9aba67b5 .config console log report ci-android-414-kasan-gce-root
2018/10/17 18:03 android-4.14 6d46bcc5a747 1ba7fd7e .config console log report ci-android-414-kasan-gce-root
2018/10/08 00:22 android-4.14 d33692e8014d 8b311eaf .config console log report ci-android-414-kasan-gce-root
2018/10/02 08:38 android-4.14 e6fa8a2046e5 e06f7713 .config console log report ci-android-414-kasan-gce-root
* Struck through repros no longer work on HEAD.