syzbot


possible deadlock in sel_write_load

Status: public: reported C repro on 2019/04/14 09:28
Reported-by: syzbot+4c8ca95bbf3da1e3d20e@syzkaller.appspotmail.com
First crash: 2078d, last: 1818d

Sample crash report:
======================================================
[ INFO: possible circular locking dependency detected ]
4.4.174+ #4 Not tainted
-------------------------------------------------------
syz-executor150/5022 is trying to acquire lock:
 (sel_mutex){+.+.+.}, at: [<ffffffff81979d7e>] sel_write_load+0x9e/0xf90 security/selinux/selinuxfs.c:511

but task is already holding lock:
 (&pipe->mutex/1){+.+.+.}, at: [<ffffffff814af8b3>] pipe_lock_nested fs/pipe.c:65 [inline]
 (&pipe->mutex/1){+.+.+.}, at: [<ffffffff814af8b3>] pipe_lock+0x63/0x80 fs/pipe.c:73

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

       [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8270c191>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff8270c191>] mutex_lock_nested+0xc1/0xb80 kernel/locking/mutex.c:621
       [<ffffffff814af8b3>] pipe_lock_nested fs/pipe.c:65 [inline]
       [<ffffffff814af8b3>] pipe_lock+0x63/0x80 fs/pipe.c:73
       [<ffffffff815342e9>] iter_file_splice_write+0x179/0xb30 fs/splice.c:974
       [<ffffffff81537d31>] do_splice_from fs/splice.c:1128 [inline]
       [<ffffffff81537d31>] do_splice fs/splice.c:1404 [inline]
       [<ffffffff81537d31>] SYSC_splice fs/splice.c:1707 [inline]
       [<ffffffff81537d31>] SyS_splice+0xd71/0x13a0 fs/splice.c:1690
       [<ffffffff82718ba1>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8149ea2f>] percpu_down_read include/linux/percpu-rwsem.h:26 [inline]
       [<ffffffff8149ea2f>] __sb_start_write+0x1af/0x310 fs/super.c:1239
       [<ffffffff816c3af4>] sb_start_write include/linux/fs.h:1517 [inline]
       [<ffffffff816c3af4>] ext4_run_li_request fs/ext4/super.c:2685 [inline]
       [<ffffffff816c3af4>] ext4_lazyinit_thread fs/ext4/super.c:2784 [inline]
       [<ffffffff816c3af4>] ext4_lazyinit_thread+0x1e4/0x7b0 fs/ext4/super.c:2760
       [<ffffffff811342c3>] kthread+0x273/0x310 kernel/kthread.c:211
       [<ffffffff82718fc5>] ret_from_fork+0x55/0x80 arch/x86/entry/entry_64.S:537

       [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8270c191>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff8270c191>] mutex_lock_nested+0xc1/0xb80 kernel/locking/mutex.c:621
       [<ffffffff816cdacd>] ext4_register_li_request+0x2fd/0x7d0 fs/ext4/super.c:2972
       [<ffffffff816cf306>] ext4_remount+0x1366/0x1b90 fs/ext4/super.c:4922
       [<ffffffff814a1ccb>] do_remount_sb2+0x41b/0x7a0 fs/super.c:781
       [<ffffffff815028ab>] do_remount fs/namespace.c:2347 [inline]
       [<ffffffff815028ab>] do_mount+0xfdb/0x2a40 fs/namespace.c:2860
       [<ffffffff81504d00>] SYSC_mount fs/namespace.c:3063 [inline]
       [<ffffffff81504d00>] SyS_mount+0x130/0x1d0 fs/namespace.c:3041
       [<ffffffff82718ba1>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8270c191>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff8270c191>] mutex_lock_nested+0xc1/0xb80 kernel/locking/mutex.c:621
       [<ffffffff816cd859>] ext4_register_li_request+0x89/0x7d0 fs/ext4/super.c:2945
       [<ffffffff816cf306>] ext4_remount+0x1366/0x1b90 fs/ext4/super.c:4922
       [<ffffffff814a1ccb>] do_remount_sb2+0x41b/0x7a0 fs/super.c:781
       [<ffffffff815028ab>] do_remount fs/namespace.c:2347 [inline]
       [<ffffffff815028ab>] do_mount+0xfdb/0x2a40 fs/namespace.c:2860
       [<ffffffff81504d00>] SYSC_mount fs/namespace.c:3063 [inline]
       [<ffffffff81504d00>] SyS_mount+0x130/0x1d0 fs/namespace.c:3041
       [<ffffffff82718ba1>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff827139a2>] down_read+0x42/0x60 kernel/locking/rwsem.c:22
       [<ffffffff814a1411>] iterate_supers+0xe1/0x250 fs/super.c:547
       [<ffffffff819b19f7>] selinux_complete_init+0x2f/0x31 security/selinux/hooks.c:6154
       [<ffffffff819a353d>] security_load_policy+0x69d/0x9c0 security/selinux/ss/services.c:2060
       [<ffffffff81979e55>] sel_write_load+0x175/0xf90 security/selinux/selinuxfs.c:535
       [<ffffffff81496916>] __vfs_write+0x116/0x3d0 fs/read_write.c:491
       [<ffffffff81498612>] vfs_write+0x182/0x4e0 fs/read_write.c:540
       [<ffffffff8149ac4c>] SYSC_write fs/read_write.c:587 [inline]
       [<ffffffff8149ac4c>] SyS_write+0xdc/0x1c0 fs/read_write.c:579
       [<ffffffff82718ba1>] entry_SYSCALL_64_fastpath+0x1e/0x9a

       [<ffffffff81202d86>] check_prev_add kernel/locking/lockdep.c:1853 [inline]
       [<ffffffff81202d86>] check_prevs_add kernel/locking/lockdep.c:1958 [inline]
       [<ffffffff81202d86>] validate_chain kernel/locking/lockdep.c:2144 [inline]
       [<ffffffff81202d86>] __lock_acquire+0x37d6/0x4f50 kernel/locking/lockdep.c:3213
       [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
       [<ffffffff8270c191>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       [<ffffffff8270c191>] mutex_lock_nested+0xc1/0xb80 kernel/locking/mutex.c:621
       [<ffffffff81979d7e>] sel_write_load+0x9e/0xf90 security/selinux/selinuxfs.c:511
       [<ffffffff81496916>] __vfs_write+0x116/0x3d0 fs/read_write.c:491
       [<ffffffff81496ce2>] __kernel_write+0x112/0x370 fs/read_write.c:513
       [<ffffffff81532e6d>] write_pipe_buf+0x15d/0x1f0 fs/splice.c:1074
       [<ffffffff81533b6e>] splice_from_pipe_feed fs/splice.c:776 [inline]
       [<ffffffff81533b6e>] __splice_from_pipe+0x37e/0x7a0 fs/splice.c:901
       [<ffffffff81536be8>] splice_from_pipe+0x108/0x170 fs/splice.c:936
       [<ffffffff81536cdc>] default_file_splice_write+0x3c/0x80 fs/splice.c:1086
       [<ffffffff81537d31>] do_splice_from fs/splice.c:1128 [inline]
       [<ffffffff81537d31>] do_splice fs/splice.c:1404 [inline]
       [<ffffffff81537d31>] SYSC_splice fs/splice.c:1707 [inline]
       [<ffffffff81537d31>] SyS_splice+0xd71/0x13a0 fs/splice.c:1690
       [<ffffffff82718ba1>] entry_SYSCALL_64_fastpath+0x1e/0x9a

other info that might help us debug this:

Chain exists of:
 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&pipe->mutex/1);
                               lock(sb_writers#4);
                               lock(&pipe->mutex/1);
  lock(sel_mutex);

 *** DEADLOCK ***

2 locks held by syz-executor150/5022:
 #0:  (sb_writers#3){.+.+.+}, at: [<ffffffff81537eed>] file_start_write include/linux/fs.h:2543 [inline]
 #0:  (sb_writers#3){.+.+.+}, at: [<ffffffff81537eed>] do_splice fs/splice.c:1403 [inline]
 #0:  (sb_writers#3){.+.+.+}, at: [<ffffffff81537eed>] SYSC_splice fs/splice.c:1707 [inline]
 #0:  (sb_writers#3){.+.+.+}, at: [<ffffffff81537eed>] SyS_splice+0xf2d/0x13a0 fs/splice.c:1690
 #1:  (&pipe->mutex/1){+.+.+.}, at: [<ffffffff814af8b3>] pipe_lock_nested fs/pipe.c:65 [inline]
 #1:  (&pipe->mutex/1){+.+.+.}, at: [<ffffffff814af8b3>] pipe_lock+0x63/0x80 fs/pipe.c:73

stack backtrace:
CPU: 0 PID: 5022 Comm: syz-executor150 Not tainted 4.4.174+ #4
 0000000000000000 68e9cd1d25b51a27 ffff8800b8307530 ffffffff81aad1a1
 ffffffff84057a80 ffff8800b0c997c0 ffffffff83ab8a20 ffffffff83abd610
 ffffffff83abc380 ffff8800b8307580 ffffffff813abcda ffffffff83e26380
Call Trace:
 [<ffffffff81aad1a1>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81aad1a1>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
 [<ffffffff813abcda>] print_circular_bug.cold+0x2f7/0x44e kernel/locking/lockdep.c:1226
 [<ffffffff81202d86>] check_prev_add kernel/locking/lockdep.c:1853 [inline]
 [<ffffffff81202d86>] check_prevs_add kernel/locking/lockdep.c:1958 [inline]
 [<ffffffff81202d86>] validate_chain kernel/locking/lockdep.c:2144 [inline]
 [<ffffffff81202d86>] __lock_acquire+0x37d6/0x4f50 kernel/locking/lockdep.c:3213
 [<ffffffff81205f6e>] lock_acquire+0x15e/0x450 kernel/locking/lockdep.c:3592
 [<ffffffff8270c191>] __mutex_lock_common kernel/locking/mutex.c:521 [inline]
 [<ffffffff8270c191>] mutex_lock_nested+0xc1/0xb80 kernel/locking/mutex.c:621
 [<ffffffff81979d7e>] sel_write_load+0x9e/0xf90 security/selinux/selinuxfs.c:511
 [<ffffffff81496916>] __vfs_write+0x116/0x3d0 fs/read_write.c:491
 [<ffffffff81496ce2>] __kernel_write+0x112/0x370 fs/read_write.c:513
 [<ffffffff81532e6d>] write_pipe_buf+0x15d/0x1f0 fs/splice.c:1074
 [<ffffffff81533b6e>] splice_from_pipe_feed fs/splice.c:776 [inline]
 [<ffffffff81533b6e>] __splice_from_pipe+0x37e/0x7a0 fs/splice.c:901
 [<ffffffff81536be8>] splice_from_pipe+0x108/0x170 fs/splice.c:936
 [<ffffffff81536cdc>] default_file_splice_write+0x3c/0x80 fs/splice.c:1086
 [<ffffffff81537d31>] do_splice_from fs/splice.c:1128 [inline]
 [<ffffffff81537d31>] do_splice fs/splice.c:1404 [inline]
 [<ffffffff81537d31>] SYSC_splice fs/splice.c:1707 [inline]
 [<ffffffff81537d31>] SyS_splice+0xd71/0x13a0 fs/splice.c:1690
 [<ffffffff82718ba1>] entry_SYSCALL_64_fastpath+0x1e/0x9a
SELinux:  policydb magic number 0x30307830 does not match expected magic number 0xf97cff8c

Crashes (31):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/08/16 21:40 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8fd428a1 .config console log report syz C ci-android-44-kasan-gce
2019/08/16 20:12 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8fd428a1 .config console log report syz ci-android-44-kasan-gce-386
2019/11/27 13:08 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce
2019/11/23 23:30 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/23 11:01 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 598ca6c8 .config console log report ci-android-44-kasan-gce
2019/11/21 18:33 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce
2019/11/13 11:57 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 048f2d49 .config console log report ci-android-44-kasan-gce
2019/10/27 03:11 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 25bb509e .config console log report ci-android-44-kasan-gce
2019/10/13 16:46 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 2f661ec4 .config console log report ci-android-44-kasan-gce
2019/10/07 02:35 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b f3f7d9c8 .config console log report ci-android-44-kasan-gce
2019/09/02 18:44 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 14544a56 .config console log report ci-android-44-kasan-gce
2019/08/30 17:57 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b fd37b39e .config console log report ci-android-44-kasan-gce
2019/08/28 04:41 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b fd37b39e .config console log report ci-android-44-kasan-gce
2019/07/31 17:36 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b c692b5bd .config console log report ci-android-44-kasan-gce
2019/03/15 11:40 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b bab43553 .config console log report ci-android-44-kasan-gce
2019/11/29 23:28 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b d29b9e84 .config console log report ci-android-44-kasan-gce-386
2019/11/27 06:14 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce-386
2019/11/27 03:35 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 1048481f .config console log report ci-android-44-kasan-gce-386
2019/11/21 22:33 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8098ea0f .config console log report ci-android-44-kasan-gce-386
2019/11/10 18:23 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b dc438b91 .config console log report ci-android-44-kasan-gce-386
2019/11/10 07:14 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b dc438b91 .config console log report ci-android-44-kasan-gce-386
2019/11/09 10:11 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b dc438b91 .config console log report ci-android-44-kasan-gce-386
2019/11/07 00:11 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b da505f84 .config console log report ci-android-44-kasan-gce-386
2019/11/05 15:48 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 0f3ec414 .config console log report ci-android-44-kasan-gce-386
2019/10/20 07:16 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8c88c9c1 .config console log report ci-android-44-kasan-gce-386
2019/10/15 07:37 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 05ad7292 .config console log report ci-android-44-kasan-gce-386
2019/10/01 11:41 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b c7a4fb99 .config console log report ci-android-44-kasan-gce-386
2019/09/07 02:48 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b a60cb4cd .config console log report ci-android-44-kasan-gce-386
2019/08/16 18:17 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 8fd428a1 .config console log report ci-android-44-kasan-gce-386
2019/05/25 08:27 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b 85c57315 .config console log report ci-android-44-kasan-gce-386
2019/04/07 03:29 https://android.googlesource.com/kernel/common android-4.4 62872f952d6b c34fde03 .config console log report ci-android-44-kasan-gce-386
* Struck through repros no longer work on HEAD.