bisecting cause commit starting from 56b697c6c13b51887a0c66c8bcbd10cd537476fa building syzkaller on e41a20c5170a991098742c4f0d04a420c2423bec testing commit 56b697c6c13b51887a0c66c8bcbd10cd537476fa with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked testing release v5.1 testing commit e93c9c99a629c61837d5a7fc2120cd2b6c70dbdd with gcc (GCC) 8.1.0 all runs: OK # git bisect start 56b697c6c13b51887a0c66c8bcbd10cd537476fa v5.1 Bisecting: 8920 revisions left to test after this (roughly 13 steps) [45182e4e1f8ac04708ca7508c51d9103f07d81ab] Merge branch 'i2c/for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux testing commit 45182e4e1f8ac04708ca7508c51d9103f07d81ab with gcc (GCC) 8.1.0 all runs: OK # git bisect good 45182e4e1f8ac04708ca7508c51d9103f07d81ab Bisecting: 4456 revisions left to test after this (roughly 12 steps) [e49c8547fb940982a04c98377bf5468a3b4a3fd4] Merge tag 'usb-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb testing commit e49c8547fb940982a04c98377bf5468a3b4a3fd4 with gcc (GCC) 8.1.0 all runs: OK # git bisect good e49c8547fb940982a04c98377bf5468a3b4a3fd4 Bisecting: 2216 revisions left to test after this (roughly 11 steps) [7989b2967a909b4ace7507430a17654d1e018d75] Merge remote-tracking branch 'wireless-drivers-next/master' testing commit 7989b2967a909b4ace7507430a17654d1e018d75 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 7989b2967a909b4ace7507430a17654d1e018d75 Bisecting: 1102 revisions left to test after this (roughly 10 steps) [b8dd9404be367fb29549942df6863034b49f1bcd] Merge remote-tracking branch 'security/next-testing' testing commit b8dd9404be367fb29549942df6863034b49f1bcd with gcc (GCC) 8.1.0 all runs: OK # git bisect good b8dd9404be367fb29549942df6863034b49f1bcd Bisecting: 549 revisions left to test after this (roughly 9 steps) [3da73e220ec0d87072f58a0113f7b61eb5b548ee] Merge remote-tracking branch 'mux/for-next' testing commit 3da73e220ec0d87072f58a0113f7b61eb5b548ee with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad 3da73e220ec0d87072f58a0113f7b61eb5b548ee Bisecting: 271 revisions left to test after this (roughly 8 steps) [68aa96efd83bac8f6a9768444e663bc90faa0bfa] Merge remote-tracking branch 'usb/usb-next' testing commit 68aa96efd83bac8f6a9768444e663bc90faa0bfa with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad 68aa96efd83bac8f6a9768444e663bc90faa0bfa Bisecting: 118 revisions left to test after this (roughly 7 steps) [5a581e85fd6577e80e447de8e4fbc6b261baa19f] Merge remote-tracking branch 'tip/auto-latest' testing commit 5a581e85fd6577e80e447de8e4fbc6b261baa19f with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad 5a581e85fd6577e80e447de8e4fbc6b261baa19f Bisecting: 87 revisions left to test after this (roughly 6 steps) [e1bc06bfe80887c3a31aadf9153a2a6297f548a5] Merge remote-tracking branch 'devicetree/for-next' testing commit e1bc06bfe80887c3a31aadf9153a2a6297f548a5 with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad e1bc06bfe80887c3a31aadf9153a2a6297f548a5 Bisecting: 37 revisions left to test after this (roughly 5 steps) [d6f11edc3bf76f1f524459c15c2204d445707611] Merge branches 'iommu/fixes', 'x86/vt-d', 'x86/amd', 'arm/renesas', 'generic-dma-ops' and 'core' into next testing commit d6f11edc3bf76f1f524459c15c2204d445707611 with gcc (GCC) 8.1.0 all runs: OK # git bisect good d6f11edc3bf76f1f524459c15c2204d445707611 Bisecting: 14 revisions left to test after this (roughly 4 steps) [e5159d8de6e07d267d7c59e4016612d8c287b23d] Merge remote-tracking branch 'tpmdd/next' testing commit e5159d8de6e07d267d7c59e4016612d8c287b23d with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad e5159d8de6e07d267d7c59e4016612d8c287b23d Bisecting: 11 revisions left to test after this (roughly 4 steps) [10160f6c00d6c8bf90f9aeb897eb0deece46ecb7] Merge remote-tracking branch 'integrity/next-integrity' testing commit 10160f6c00d6c8bf90f9aeb897eb0deece46ecb7 with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad 10160f6c00d6c8bf90f9aeb897eb0deece46ecb7 Bisecting: 5 revisions left to test after this (roughly 3 steps) [058c4f342582362c75dd5e162dc4ff73a392ffad] apparmor: fix spelling mistake "immutible" -> "immutable" testing commit 058c4f342582362c75dd5e162dc4ff73a392ffad with gcc (GCC) 8.1.0 all runs: OK # git bisect good 058c4f342582362c75dd5e162dc4ff73a392ffad Bisecting: 2 revisions left to test after this (roughly 2 steps) [8902b36bab4c9022432bebc17774fe8d4e3bee7e] ima: prevent a file already mmap'ed write to be mmap'ed execute testing commit 8902b36bab4c9022432bebc17774fe8d4e3bee7e with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad 8902b36bab4c9022432bebc17774fe8d4e3bee7e Bisecting: 0 revisions left to test after this (roughly 1 step) [69d61f577d147b396be0991b2ac6f65057f7d445] ima: verify mprotect change is consistent with mmap policy testing commit 69d61f577d147b396be0991b2ac6f65057f7d445 with gcc (GCC) 8.1.0 all runs: crashed: possible deadlock in get_user_pages_unlocked # git bisect bad 69d61f577d147b396be0991b2ac6f65057f7d445 Bisecting: 0 revisions left to test after this (roughly 0 steps) [980ef4d22a95a3cd84a9b8ffaa7b81b391d173c6] x86/ima: check EFI SetupMode too testing commit 980ef4d22a95a3cd84a9b8ffaa7b81b391d173c6 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 980ef4d22a95a3cd84a9b8ffaa7b81b391d173c6 69d61f577d147b396be0991b2ac6f65057f7d445 is the first bad commit commit 69d61f577d147b396be0991b2ac6f65057f7d445 Author: Mimi Zohar Date: Wed Apr 3 17:47:46 2019 -0400 ima: verify mprotect change is consistent with mmap policy IMA can be configured to measure and appraise a file's integrity being mmap'ed execute. Files can be mmap'ed read/write and later changed to execute to circumvent IMA's mmap measurement and appraisal policy rules. To prevent this from happening, this patch similarly calls ima_file_mmap() for mprotect changes. Suggested-by: Stephen Smalley Signed-off-by: Mimi Zohar :040000 040000 f557ca0e06c6bf3842a9d9d5c24ffe8575dd32dd a472fa46897ea0d4a7fd714fabb9aac3f7cc9bff M security revisions tested: 17, total time: 3h56m24.946690406s (build: 1h36m35.761407082s, test: 2h14m17.455454656s) first bad commit: 69d61f577d147b396be0991b2ac6f65057f7d445 ima: verify mprotect change is consistent with mmap policy cc: ["jmorris@namei.org" "linux-kernel@vger.kernel.org" "linux-security-module@vger.kernel.org" "serge@hallyn.com" "zohar@linux.ibm.com"] crash: possible deadlock in get_user_pages_unlocked ====================================================== WARNING: possible circular locking dependency detected 5.2.0-rc1+ #1 Not tainted ------------------------------------------------------ syz-executor.3/7565 is trying to acquire lock: 000000008b66ea85 (&mm->mmap_sem#2){++++}, at: get_user_pages_unlocked+0xe2/0x2d0 mm/gup.c:1172 but task is already holding lock: 0000000025b01b69 (&sb->s_type->i_mutex_key#10){+.+.}, at: inode_trylock include/linux/fs.h:798 [inline] 0000000025b01b69 (&sb->s_type->i_mutex_key#10){+.+.}, at: ext4_file_write_iter+0x1e9/0xe90 fs/ext4/file.c:232 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&sb->s_type->i_mutex_key#10){+.+.}: down_write+0x38/0xa0 kernel/locking/rwsem.c:66 inode_lock include/linux/fs.h:778 [inline] process_measurement+0x69e/0x14b0 security/integrity/ima/ima_main.c:207 ima_file_mmap+0xf0/0x110 security/integrity/ima/ima_main.c:342 security_file_mprotect+0x91/0xc0 security/security.c:1430 do_mprotect_pkey+0x3b7/0x7f0 mm/mprotect.c:550 __do_sys_mprotect mm/mprotect.c:582 [inline] __se_sys_mprotect mm/mprotect.c:579 [inline] __x64_sys_mprotect+0x73/0xb0 mm/mprotect.c:579 do_syscall_64+0xd0/0x530 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #0 (&mm->mmap_sem#2){++++}: lock_acquire+0x173/0x3d0 kernel/locking/lockdep.c:4302 down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24 get_user_pages_unlocked+0xe2/0x2d0 mm/gup.c:1172 __gup_longterm_unlocked mm/gup.c:2191 [inline] get_user_pages_fast+0x318/0x440 mm/gup.c:2243 iov_iter_get_pages+0x200/0x1260 lib/iov_iter.c:1286 dio_refill_pages fs/direct-io.c:170 [inline] dio_get_page fs/direct-io.c:214 [inline] do_direct_IO fs/direct-io.c:982 [inline] do_blockdev_direct_IO+0x38dd/0x6f00 fs/direct-io.c:1335 __blockdev_direct_IO+0x72/0xd9 fs/direct-io.c:1421 ext4_direct_IO_write fs/ext4/inode.c:3772 [inline] ext4_direct_IO+0x86c/0x1670 fs/ext4/inode.c:3899 generic_file_direct_write+0x1e7/0x400 mm/filemap.c:3108 __generic_file_write_iter+0x270/0x580 mm/filemap.c:3291 ext4_file_write_iter+0x288/0xe90 fs/ext4/file.c:266 call_write_iter include/linux/fs.h:1872 [inline] new_sync_write+0x3fd/0x7e0 fs/read_write.c:483 __vfs_write+0x94/0x110 fs/read_write.c:496 vfs_write+0x150/0x4e0 fs/read_write.c:558 ksys_write+0x105/0x220 fs/read_write.c:611 __do_sys_write fs/read_write.c:623 [inline] __se_sys_write fs/read_write.c:620 [inline] __x64_sys_write+0x6e/0xb0 fs/read_write.c:620 do_syscall_64+0xd0/0x530 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sb->s_type->i_mutex_key#10); lock(&mm->mmap_sem#2); lock(&sb->s_type->i_mutex_key#10); lock(&mm->mmap_sem#2); *** DEADLOCK *** 3 locks held by syz-executor.3/7565: #0: 0000000042532698 (&f->f_pos_lock){+.+.}, at: __fdget_pos+0xa7/0xd0 fs/file.c:801 #1: 0000000082e07cc5 (sb_writers#3){.+.+}, at: file_start_write include/linux/fs.h:2837 [inline] #1: 0000000082e07cc5 (sb_writers#3){.+.+}, at: vfs_write+0x321/0x4e0 fs/read_write.c:557 #2: 0000000025b01b69 (&sb->s_type->i_mutex_key#10){+.+.}, at: inode_trylock include/linux/fs.h:798 [inline] #2: 0000000025b01b69 (&sb->s_type->i_mutex_key#10){+.+.}, at: ext4_file_write_iter+0x1e9/0xe90 fs/ext4/file.c:232 stack backtrace: CPU: 0 PID: 7565 Comm: syz-executor.3 Not tainted 5.2.0-rc1+ #1 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+0x113/0x167 lib/dump_stack.c:113 print_circular_bug.cold.59+0x1bd/0x27d kernel/locking/lockdep.c:1564 check_prev_add kernel/locking/lockdep.c:2309 [inline] check_prevs_add kernel/locking/lockdep.c:2417 [inline] validate_chain kernel/locking/lockdep.c:2799 [inline] __lock_acquire+0x3853/0x55b0 kernel/locking/lockdep.c:3792 lock_acquire+0x173/0x3d0 kernel/locking/lockdep.c:4302 down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24 get_user_pages_unlocked+0xe2/0x2d0 mm/gup.c:1172 __gup_longterm_unlocked mm/gup.c:2191 [inline] get_user_pages_fast+0x318/0x440 mm/gup.c:2243 iov_iter_get_pages+0x200/0x1260 lib/iov_iter.c:1286 dio_refill_pages fs/direct-io.c:170 [inline] dio_get_page fs/direct-io.c:214 [inline] do_direct_IO fs/direct-io.c:982 [inline] do_blockdev_direct_IO+0x38dd/0x6f00 fs/direct-io.c:1335 __blockdev_direct_IO+0x72/0xd9 fs/direct-io.c:1421 ext4_direct_IO_write fs/ext4/inode.c:3772 [inline] ext4_direct_IO+0x86c/0x1670 fs/ext4/inode.c:3899 generic_file_direct_write+0x1e7/0x400 mm/filemap.c:3108 __generic_file_write_iter+0x270/0x580 mm/filemap.c:3291 ext4_file_write_iter+0x288/0xe90 fs/ext4/file.c:266 call_write_iter include/linux/fs.h:1872 [inline] new_sync_write+0x3fd/0x7e0 fs/read_write.c:483 __vfs_write+0x94/0x110 fs/read_write.c:496 vfs_write+0x150/0x4e0 fs/read_write.c:558 ksys_write+0x105/0x220 fs/read_write.c:611 __do_sys_write fs/read_write.c:623 [inline] __se_sys_write fs/read_write.c:620 [inline] __x64_sys_write+0x6e/0xb0 fs/read_write.c:620 do_syscall_64+0xd0/0x530 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x459279 Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f1afb4dbc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459279 RDX: 0000000020000012 RSI: 0000000020000000 RDI: 0000000000000005 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1afb4dc6d4 R13: 00000000004c8ec2 R14: 00000000004dfb80 R15: 00000000ffffffff