possible deadlock in sel_read_policy

8 views
Skip to first unread message

syzbot

unread,
Apr 11, 2019, 4:44:39 AM4/11/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: b2cf10ee ANDROID: arm64: mm: fix 4.4.154 merge
git tree: android-4.4
console output: https://syzkaller.appspot.com/x/log.txt?x=15be498e400000
kernel config: https://syzkaller.appspot.com/x/.config?x=7e912d922815a1c1
dashboard link: https://syzkaller.appspot.com/bug?extid=02c4b067db4343413f4c
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
userspace arch: i386
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b8c149400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11210dea400000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+02c4b0...@syzkaller.appspotmail.com


======================================================
[ 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


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages