syzbot


possible deadlock in sel_read_policy

Status: public: reported C repro on 2019/04/11 08:44
Reported-by: syzbot+02c4b067db4343413f4c@syzkaller.appspotmail.com
First crash: 2268d, last: 1814d

Sample crash report:
======================================================
[ INFO: possible circular locking dependency detected ]
4.4.154+ #32 Not tainted
-------------------------------------------------------
syz-executor637/2264 is trying to acquire lock:
 (sel_mutex){+.+.+.}, at: [<ffffffff819248f9>] sel_read_policy+0x59/0x110 security/selinux/selinuxfs.c:441

but task is already holding lock:
 (sb_writers#4){.+.+.+}, at: [<ffffffff8147650a>] file_start_write include/linux/fs.h:2541 [inline]
 (sb_writers#4){.+.+.+}, at: [<ffffffff8147650a>] do_sendfile+0x89a/0xb80 fs/read_write.c:1226

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

       [<ffffffff811fa79e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8147a82e>] percpu_down_read include/linux/percpu-rwsem.h:26 [inline]
       [<ffffffff8147a82e>] __sb_start_write+0x1ae/0x310 fs/super.c:1221
       [<ffffffff81690a37>] sb_start_write include/linux/fs.h:1515 [inline]
       [<ffffffff81690a37>] ext4_run_li_request fs/ext4/super.c:2674 [inline]
       [<ffffffff81690a37>] ext4_lazyinit_thread+0x1a7/0x750 fs/ext4/super.c:2773
       [<ffffffff8112ee98>] kthread+0x268/0x300 kernel/kthread.c:211
       [<ffffffff82690905>] ret_from_fork+0x55/0x80 arch/x86/entry/entry_64.S:510

       [<ffffffff811fa79e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff82685dcb>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff82685dcb>] mutex_lock_nested+0xbb/0x840 kernel/locking/mutex.c:621
       [<ffffffff8169ac24>] ext4_register_li_request+0x304/0x6c0 fs/ext4/super.c:2961
       [<ffffffff8169c348>] ext4_remount+0x1368/0x1bb0 fs/ext4/super.c:4909
       [<ffffffff8147d968>] do_remount_sb2+0x428/0x7d0 fs/super.c:771
       [<ffffffff814db04e>] do_remount fs/namespace.c:2335 [inline]
       [<ffffffff814db04e>] do_mount+0x101e/0x28f0 fs/namespace.c:2848
       [<ffffffff814dd391>] SYSC_mount fs/namespace.c:3051 [inline]
       [<ffffffff814dd391>] SyS_mount+0x191/0x1c0 fs/namespace.c:3029
       [<ffffffff82690521>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff811fa79e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff82685dcb>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff82685dcb>] mutex_lock_nested+0xbb/0x840 kernel/locking/mutex.c:621
       [<ffffffff8169a9a7>] ext4_register_li_request+0x87/0x6c0 fs/ext4/super.c:2934
       [<ffffffff8169c348>] ext4_remount+0x1368/0x1bb0 fs/ext4/super.c:4909
       [<ffffffff8147d968>] do_remount_sb2+0x428/0x7d0 fs/super.c:771
       [<ffffffff814db04e>] do_remount fs/namespace.c:2335 [inline]
       [<ffffffff814db04e>] do_mount+0x101e/0x28f0 fs/namespace.c:2848
       [<ffffffff814dd391>] SYSC_mount fs/namespace.c:3051 [inline]
       [<ffffffff814dd391>] SyS_mount+0x191/0x1c0 fs/namespace.c:3029
       [<ffffffff82690521>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff811fa79e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8268b972>] down_read+0x42/0x60 kernel/locking/rwsem.c:22
       [<ffffffff8147d081>] iterate_supers+0xe1/0x260 fs/super.c:537
       [<ffffffff8195f423>] selinux_complete_init+0x2f/0x31 security/selinux/hooks.c:6154
       [<ffffffff81951156>] security_load_policy+0x886/0x9b0 security/selinux/ss/services.c:2060
       [<ffffffff81927731>] sel_write_load+0x191/0xfc0 security/selinux/selinuxfs.c:535
       [<ffffffff814727cc>] __vfs_write+0x11c/0x3e0 fs/read_write.c:489
       [<ffffffff8147444e>] vfs_write+0x17e/0x4e0 fs/read_write.c:538
       [<ffffffff81476a89>] SYSC_write fs/read_write.c:585 [inline]
       [<ffffffff81476a89>] SyS_write+0xd9/0x1c0 fs/read_write.c:577
       [<ffffffff82690521>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff811f6e4e>] check_prev_add kernel/locking/lockdep.c:1853 [inline]
       [<ffffffff811f6e4e>] check_prevs_add kernel/locking/lockdep.c:1958 [inline]
       [<ffffffff811f6e4e>] validate_chain kernel/locking/lockdep.c:2144 [inline]
       [<ffffffff811f6e4e>] __lock_acquire+0x3b6e/0x5ba0 kernel/locking/lockdep.c:3213
       [<ffffffff811fa79e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff82685dcb>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff82685dcb>] mutex_lock_nested+0xbb/0x840 kernel/locking/mutex.c:621
       [<ffffffff819248f9>] sel_read_policy+0x59/0x110 security/selinux/selinuxfs.c:441
       [<ffffffff81472ef8>] do_loop_readv_writev+0x148/0x1e0 fs/read_write.c:680
       [<ffffffff81474d31>] do_readv_writev+0x581/0x6f0 fs/read_write.c:810
       [<ffffffff81474f18>] vfs_readv+0x78/0xb0 fs/read_write.c:834
       [<ffffffff8150c8cb>] kernel_readv fs/splice.c:586 [inline]
       [<ffffffff8150c8cb>] default_file_splice_read+0x4fb/0x8d0 fs/splice.c:662
       [<ffffffff815087b7>] do_splice_to+0xf7/0x140 fs/splice.c:1154
       [<ffffffff81508a42>] splice_direct_to_actor+0x242/0x830 fs/splice.c:1226
       [<ffffffff815091d3>] do_splice_direct+0x1a3/0x270 fs/splice.c:1337
       [<ffffffff81476154>] do_sendfile+0x4e4/0xb80 fs/read_write.c:1227
       [<ffffffff81478143>] SYSC_sendfile64 fs/read_write.c:1282 [inline]
       [<ffffffff81478143>] SyS_sendfile64+0xc3/0x150 fs/read_write.c:1274
       [<ffffffff81005ffe>] do_syscall_32_irqs_on arch/x86/entry/common.c:393 [inline]
       [<ffffffff81005ffe>] do_fast_syscall_32+0x31e/0x8b0 arch/x86/entry/common.c:460
       [<ffffffff82691c90>] sysenter_flags_fixed+0xd/0x1a

other info that might help us debug this:

Chain exists of:
 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sb_writers#4);
                               lock(&eli->li_list_mtx);
                               lock(sb_writers#4);
  lock(sel_mutex);

 *** DEADLOCK ***

1 lock held by syz-executor637/2264:
 #0:  (sb_writers#4){.+.+.+}, at: [<ffffffff8147650a>] file_start_write include/linux/fs.h:2541 [inline]
 #0:  (sb_writers#4){.+.+.+}, at: [<ffffffff8147650a>] do_sendfile+0x89a/0xb80 fs/read_write.c:1226

stack backtrace:
CPU: 0 PID: 2264 Comm: syz-executor637 Not tainted 4.4.154+ #32
 0000000000000000 6724c3dca7ea76cc ffff8801ca84f068 ffffffff81a54fed
 ffffffff83abea60 ffffffff83ab2190 ffffffff83aae830 ffff8801cb3da0a8
 ffff8801cb3d97c0 ffff8801ca84f0b0 ffffffff81391d2f 0000000000000001
Call Trace:
 [<ffffffff81a54fed>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81a54fed>] dump_stack+0xc1/0x124 lib/dump_stack.c:51
 [<ffffffff81391d2f>] print_circular_bug.cold.34+0x2f7/0x432 kernel/locking/lockdep.c:1226
 [<ffffffff811f6e4e>] check_prev_add kernel/locking/lockdep.c:1853 [inline]
 [<ffffffff811f6e4e>] check_prevs_add kernel/locking/lockdep.c:1958 [inline]
 [<ffffffff811f6e4e>] validate_chain kernel/locking/lockdep.c:2144 [inline]
 [<ffffffff811f6e4e>] __lock_acquire+0x3b6e/0x5ba0 kernel/locking/lockdep.c:3213
 [<ffffffff811fa79e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
 [<ffffffff82685dcb>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
 [<ffffffff82685dcb>] mutex_lock_nested+0xbb/0x840 kernel/locking/mutex.c:621
 [<ffffffff819248f9>] sel_read_policy+0x59/0x110 security/selinux/selinuxfs.c:441
 [<ffffffff81472ef8>] do_loop_readv_writev+0x148/0x1e0 fs/read_write.c:680
 [<ffffffff81474d31>] do_readv_writev+0x581/0x6f0 fs/read_write.c:810
 [<ffffffff81474f18>] vfs_readv+0x78/0xb0 fs/read_write.c:834
 [<ffffffff8150c8cb>] kernel_readv fs/splice.c:586 [inline]
 [<ffffffff8150c8cb>] default_file_splice_read+0x4fb/0x8d0 fs/splice.c:662
 [<ffffffff815087b7>] do_splice_to+0xf7/0x140 fs/splice.c:1154
 [<ffffffff81508a42>] splice_direct_to_actor+0x242/0x830 fs/splice.c:1226
 [<ffffffff815091d3>] do_splice_direct+0x1a3/0x270 fs/splice.c:1337
 [<ffffffff81476154>] do_sendfile+0x4e4/0xb80 fs/read_write.c:1227
 [<ffffffff81478143>] SYSC_sendfile64 fs/read_write.c:1282 [inline]
 [<ffffffff81478143>] SyS_sendfile64+0xc3/0x150 fs/read_write.c:1274
 [<ffffffff81005ffe>] do_syscall_32_irqs_on arch/x86/entry/common.c:393 [inline]
 [<ffffffff81005ffe>] do_fast_syscall_32+0x31e/0x8b0 arch/x86/entry/common.c:460
 [<ffffffff82691c90>] sysenter_flags_fixed+0xd/0x1a

Crashes (934):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/09/06 07:52 https://android.googlesource.com/kernel/common android-4.4 b2cf10ee86d7 873745f2 .config console log report syz C ci-android-44-kasan-gce-386
2019/12/01 14:41 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b a76bf83f .config console log report ci-android-44-kasan-gce
2019/11/30 09:08 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 3a75be00 .config console log report ci-android-44-kasan-gce
2019/11/29 16:09 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b d29b9e84 .config console log report ci-android-44-kasan-gce
2019/11/28 08:49 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 0d63f89c .config console log report ci-android-44-kasan-gce
2019/11/27 10:56 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce
2019/11/27 07:04 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce
2019/11/25 17:22 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 371caf77 .config console log report ci-android-44-kasan-gce
2019/11/24 14:13 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/24 05:04 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/23 22:34 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/23 20:55 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/23 18:26 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/23 15:21 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/21 23:36 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce
2019/12/04 02:08 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b ae13a849 .config console log report ci-android-44-kasan-gce-386
2019/12/03 15:50 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b ab342da3 .config console log report ci-android-44-kasan-gce-386
2019/12/03 04:18 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b ab342da3 .config console log report ci-android-44-kasan-gce-386
2019/12/02 12:09 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b f879db37 .config console log report ci-android-44-kasan-gce-386
2019/12/02 08:25 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b f879db37 .config console log report ci-android-44-kasan-gce-386
2019/12/01 17:09 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b a76bf83f .config console log report ci-android-44-kasan-gce-386
2019/12/01 12:27 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b a76bf83f .config console log report ci-android-44-kasan-gce-386
2019/12/01 06:37 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b a76bf83f .config console log report ci-android-44-kasan-gce-386
2019/11/30 16:34 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 3a75be00 .config console log report ci-android-44-kasan-gce-386
2019/11/30 13:02 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 3a75be00 .config console log report ci-android-44-kasan-gce-386
2019/11/30 11:01 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 3a75be00 .config console log report ci-android-44-kasan-gce-386
2019/11/30 09:42 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 3a75be00 .config console log report ci-android-44-kasan-gce-386
2019/11/29 18:52 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b d29b9e84 .config console log report ci-android-44-kasan-gce-386
2019/11/29 03:06 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 76357d6f .config console log report ci-android-44-kasan-gce-386
2019/11/28 01:01 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 0d63f89c .config console log report ci-android-44-kasan-gce-386
2019/11/27 09:49 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce-386
2019/11/26 21:16 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce-386
2019/11/25 12:49 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 371caf77 .config console log report ci-android-44-kasan-gce-386
2019/11/25 05:09 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/24 23:01 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/24 21:08 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/24 17:04 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/23 10:48 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/23 04:59 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/23 00:25 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/22 22:53 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce-386
2019/11/22 10:32 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce-386
2019/11/22 01:10 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce-386
2019/11/21 19:49 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce-386
2019/11/21 17:57 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce-386
2019/11/21 16:34 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce-386
2018/09/06 06:28 https://android.googlesource.com/kernel/common android-4.4 b2cf10ee86d7 873745f2 .config console log report ci-android-44-kasan-gce-386
* Struck through repros no longer work on HEAD.