* possible deadlock in get_user_pages_unlocked (2)
@ 2019-06-01 6:08 syzbot
2019-06-04 21:19 ` syzbot
2019-06-05 1:16 ` syzbot
0 siblings, 2 replies; 4+ messages in thread
From: syzbot @ 2019-06-01 6:08 UTC (permalink / raw)
To: akpm, aneesh.kumar, dan.j.williams, ira.weiny, jhubbard,
keith.busch, linux-kernel, linux-mm, rppt, sfr, syzkaller-bugs
Hello,
syzbot found the following crash on:
HEAD commit: 3c09c195 Add linux-next specific files for 20190531
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=13b36b9aa00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6cfb24468280cd5c
dashboard link: https://syzkaller.appspot.com/bug?extid=e1374b2ec8f6a25ab2e5
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
Unfortunately, I don't have any reproducer for this crash yet.
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+e1374b2ec8f6a25ab2e5@syzkaller.appspotmail.com
======================================================
WARNING: possible circular locking dependency detected
5.2.0-rc2-next-20190531 #4 Not tainted
------------------------------------------------------
syz-executor.5/29536 is trying to acquire lock:
0000000031b33a56 (&mm->mmap_sem#2){++++}, at:
get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
but task is already holding lock:
00000000e8d693f5 (&sb->s_type->i_mutex_key#10){++++}, at: inode_trylock
include/linux/fs.h:798 [inline]
00000000e8d693f5 (&sb->s_type->i_mutex_key#10){++++}, at:
ext4_file_write_iter+0x246/0x1070 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+0x15ae/0x15e0
security/integrity/ima/ima_main.c:228
ima_file_mmap+0x11a/0x130 security/integrity/ima/ima_main.c:370
security_file_mprotect+0xd5/0x100 security/security.c:1430
do_mprotect_pkey+0x537/0xa30 mm/mprotect.c:550
__do_sys_pkey_mprotect mm/mprotect.c:590 [inline]
__se_sys_pkey_mprotect mm/mprotect.c:587 [inline]
__x64_sys_pkey_mprotect+0x97/0xf0 mm/mprotect.c:587
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
-> #0 (&mm->mmap_sem#2){++++}:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4300
down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24
get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
__gup_longterm_unlocked mm/gup.c:2193 [inline]
get_user_pages_fast+0x43f/0x530 mm/gup.c:2245
iov_iter_get_pages+0x2c2/0xf80 lib/iov_iter.c:1287
dio_refill_pages fs/direct-io.c:171 [inline]
dio_get_page fs/direct-io.c:215 [inline]
do_direct_IO fs/direct-io.c:983 [inline]
do_blockdev_direct_IO+0x3f7b/0x8e00 fs/direct-io.c:1336
__blockdev_direct_IO+0xa1/0xca fs/direct-io.c:1422
ext4_direct_IO_write fs/ext4/inode.c:3782 [inline]
ext4_direct_IO+0xaa7/0x1bb0 fs/ext4/inode.c:3909
generic_file_direct_write+0x20a/0x4a0 mm/filemap.c:3110
__generic_file_write_iter+0x2ee/0x630 mm/filemap.c:3293
ext4_file_write_iter+0x332/0x1070 fs/ext4/file.c:266
call_write_iter include/linux/fs.h:1870 [inline]
new_sync_write+0x4d3/0x770 fs/read_write.c:483
__vfs_write+0xe1/0x110 fs/read_write.c:496
vfs_write+0x268/0x5d0 fs/read_write.c:558
ksys_write+0x14f/0x290 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+0x73/0xb0 fs/read_write.c:620
do_syscall_64+0xfd/0x680 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.5/29536:
#0: 000000007070e315 (&f->f_pos_lock){+.+.}, at: __fdget_pos+0xee/0x110
fs/file.c:801
#1: 000000001278f3d0 (sb_writers#3){.+.+}, at: file_start_write
include/linux/fs.h:2836 [inline]
#1: 000000001278f3d0 (sb_writers#3){.+.+}, at: vfs_write+0x485/0x5d0
fs/read_write.c:557
#2: 00000000e8d693f5 (&sb->s_type->i_mutex_key#10){++++}, at:
inode_trylock include/linux/fs.h:798 [inline]
#2: 00000000e8d693f5 (&sb->s_type->i_mutex_key#10){++++}, at:
ext4_file_write_iter+0x246/0x1070 fs/ext4/file.c:232
stack backtrace:
CPU: 0 PID: 29536 Comm: syz-executor.5 Not tainted 5.2.0-rc2-next-20190531
#4
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+0x172/0x1f0 lib/dump_stack.c:113
print_circular_bug.cold+0x1cc/0x28f kernel/locking/lockdep.c:1566
check_prev_add kernel/locking/lockdep.c:2311 [inline]
check_prevs_add kernel/locking/lockdep.c:2419 [inline]
validate_chain kernel/locking/lockdep.c:2801 [inline]
__lock_acquire+0x3755/0x5490 kernel/locking/lockdep.c:3790
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4300
down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24
get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
__gup_longterm_unlocked mm/gup.c:2193 [inline]
get_user_pages_fast+0x43f/0x530 mm/gup.c:2245
iov_iter_get_pages+0x2c2/0xf80 lib/iov_iter.c:1287
dio_refill_pages fs/direct-io.c:171 [inline]
dio_get_page fs/direct-io.c:215 [inline]
do_direct_IO fs/direct-io.c:983 [inline]
do_blockdev_direct_IO+0x3f7b/0x8e00 fs/direct-io.c:1336
__blockdev_direct_IO+0xa1/0xca fs/direct-io.c:1422
ext4_direct_IO_write fs/ext4/inode.c:3782 [inline]
ext4_direct_IO+0xaa7/0x1bb0 fs/ext4/inode.c:3909
generic_file_direct_write+0x20a/0x4a0 mm/filemap.c:3110
__generic_file_write_iter+0x2ee/0x630 mm/filemap.c:3293
ext4_file_write_iter+0x332/0x1070 fs/ext4/file.c:266
call_write_iter include/linux/fs.h:1870 [inline]
new_sync_write+0x4d3/0x770 fs/read_write.c:483
__vfs_write+0xe1/0x110 fs/read_write.c:496
vfs_write+0x268/0x5d0 fs/read_write.c:558
ksys_write+0x14f/0x290 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+0x73/0xb0 fs/read_write.c:620
do_syscall_64+0xfd/0x680 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:00007f65e9a0fc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459279
RDX: 000000010000000d RSI: 0000000020000000 RDI: 0000000000000004
RBP: 000000000075bfc0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f65e9a106d4
R13: 00000000004c8e8a R14: 00000000004dfae0 R15: 00000000ffffffff
---
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 syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: possible deadlock in get_user_pages_unlocked (2)
2019-06-01 6:08 possible deadlock in get_user_pages_unlocked (2) syzbot
@ 2019-06-04 21:19 ` syzbot
2019-06-05 1:16 ` syzbot
1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2019-06-04 21:19 UTC (permalink / raw)
To: akpm, aneesh.kumar, dan.j.williams, ira.weiny, jhubbard,
keith.busch, linux-kernel, linux-mm, rppt, sfr, syzkaller-bugs
syzbot has found a reproducer for the following crash on:
HEAD commit: 56b697c6 Add linux-next specific files for 20190604
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=13241716a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=4248d6bc70076f7d
dashboard link: https://syzkaller.appspot.com/bug?extid=e1374b2ec8f6a25ab2e5
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=165757eea00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dd3e86a00000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+e1374b2ec8f6a25ab2e5@syzkaller.appspotmail.com
IPVS: ftp: loaded support on port[0] = 21
======================================================
WARNING: possible circular locking dependency detected
5.2.0-rc3-next-20190604 #8 Not tainted
------------------------------------------------------
syz-executor842/8767 is trying to acquire lock:
00000000badb3a6d (&mm->mmap_sem#2){++++}, at:
get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
but task is already holding lock:
0000000052562d44 (&sb->s_type->i_mutex_key#10){+.+.}, at: inode_trylock
include/linux/fs.h:798 [inline]
0000000052562d44 (&sb->s_type->i_mutex_key#10){+.+.}, at:
ext4_file_write_iter+0x246/0x1070 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+0x15ae/0x15e0
security/integrity/ima/ima_main.c:228
ima_file_mmap+0x11a/0x130 security/integrity/ima/ima_main.c:370
security_file_mprotect+0xd5/0x100 security/security.c:1426
do_mprotect_pkey+0x537/0xa30 mm/mprotect.c:550
__do_sys_mprotect mm/mprotect.c:582 [inline]
__se_sys_mprotect mm/mprotect.c:579 [inline]
__x64_sys_mprotect+0x78/0xb0 mm/mprotect.c:579
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
-> #0 (&mm->mmap_sem#2){++++}:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4300
down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24
get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
__gup_longterm_unlocked mm/gup.c:2193 [inline]
get_user_pages_fast+0x43f/0x530 mm/gup.c:2245
iov_iter_get_pages+0x2c2/0xf80 lib/iov_iter.c:1287
dio_refill_pages fs/direct-io.c:171 [inline]
dio_get_page fs/direct-io.c:215 [inline]
do_direct_IO fs/direct-io.c:983 [inline]
do_blockdev_direct_IO+0x3f7b/0x8e00 fs/direct-io.c:1336
__blockdev_direct_IO+0xa1/0xca fs/direct-io.c:1422
ext4_direct_IO_write fs/ext4/inode.c:3782 [inline]
ext4_direct_IO+0xaa7/0x1bb0 fs/ext4/inode.c:3909
generic_file_direct_write+0x20a/0x4a0 mm/filemap.c:3110
__generic_file_write_iter+0x2ee/0x630 mm/filemap.c:3293
ext4_file_write_iter+0x332/0x1070 fs/ext4/file.c:266
call_write_iter include/linux/fs.h:1870 [inline]
new_sync_write+0x4d3/0x770 fs/read_write.c:483
__vfs_write+0xe1/0x110 fs/read_write.c:496
vfs_write+0x268/0x5d0 fs/read_write.c:558
ksys_write+0x14f/0x290 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+0x73/0xb0 fs/read_write.c:620
do_syscall_64+0xfd/0x680 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 ***
2 locks held by syz-executor842/8767:
#0: 0000000065e8e19a (sb_writers#3){.+.+}, at: file_start_write
include/linux/fs.h:2836 [inline]
#0: 0000000065e8e19a (sb_writers#3){.+.+}, at: vfs_write+0x485/0x5d0
fs/read_write.c:557
#1: 0000000052562d44 (&sb->s_type->i_mutex_key#10){+.+.}, at:
inode_trylock include/linux/fs.h:798 [inline]
#1: 0000000052562d44 (&sb->s_type->i_mutex_key#10){+.+.}, at:
ext4_file_write_iter+0x246/0x1070 fs/ext4/file.c:232
stack backtrace:
CPU: 0 PID: 8767 Comm: syz-executor842 Not tainted 5.2.0-rc3-next-20190604
#8
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+0x172/0x1f0 lib/dump_stack.c:113
print_circular_bug.cold+0x1cc/0x28f kernel/locking/lockdep.c:1566
check_prev_add kernel/locking/lockdep.c:2311 [inline]
check_prevs_add kernel/locking/lockdep.c:2419 [inline]
validate_chain kernel/locking/lockdep.c:2801 [inline]
__lock_acquire+0x3755/0x5490 kernel/locking/lockdep.c:3790
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4300
down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24
get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
__gup_longterm_unlocked mm/gup.c:2193 [inline]
get_user_pages_fast+0x43f/0x530 mm/gup.c:2245
iov_iter_get_pages+0x2c2/0xf80 lib/iov_iter.c:1287
dio_refill_pages fs/direct-io.c:171 [inline]
dio_get_page fs/direct-io.c:215 [inline]
do_direct_IO fs/direct-io.c:983 [inline]
do_blockdev_direct_IO+0x3f7b/0x8e00 fs/direct-io.c:1336
? 0xffffffff81000000
__blockdev_direct_IO+0xa1/0xca fs/direct-io.c:1422
ext4_direct_IO_write fs/ext4/inode.c:3782 [inline]
ext4_direct_IO+0xaa7/0x1bb0 fs/ext4/inode.c:3909
generic_file_direct_write+0x20a/0x4a0 mm/filemap.c:3110
__generic_file_write_iter+0x2ee/0x630 mm/filemap.c:3293
ext4_file_write_iter+0x332/0x1070 fs/ext4/file.c:266
call_write_iter include/linux/fs.h:1870 [inline]
new_sync_write+0x4d3/0x770 fs/read_write.c:483
__vfs_write+0xe1/0x110 fs/read_write.c:496
vfs_write+0x268/0x5d0 fs/read_write.c:558
ksys_write+0x14f/0x290 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+0x73/0xb0 fs/read_write.c:620
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440a49
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 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 bb 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc18e28968 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000004a22e0 RCX: 0000000000440a49
RDX: 0000000020000012 RSI: 0000000020000000 RDI: 0000000000000005
RBP: 00000000004a2370 R08: 0000000000000012 R09: 0000000000000100
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401f90
R13: 0000000000402020 R14: 0000000000000000 R15: 0000000000000000
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: possible deadlock in get_user_pages_unlocked (2)
2019-06-01 6:08 possible deadlock in get_user_pages_unlocked (2) syzbot
2019-06-04 21:19 ` syzbot
@ 2019-06-05 1:16 ` syzbot
2019-06-10 19:06 ` [IMA] " Eric Biggers
1 sibling, 1 reply; 4+ messages in thread
From: syzbot @ 2019-06-05 1:16 UTC (permalink / raw)
To: akpm, aneesh.kumar, dan.j.williams, ira.weiny, jack, jhubbard,
jmorris, keith.busch, linux-kernel, linux-mm,
linux-security-module, richard.weiyang, rppt, serge, sfr,
syzkaller-bugs, willy, zohar
syzbot has bisected this bug to:
commit 69d61f577d147b396be0991b2ac6f65057f7d445
Author: Mimi Zohar <zohar@linux.ibm.com>
Date: Wed Apr 3 21:47:46 2019 +0000
ima: verify mprotect change is consistent with mmap policy
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1055a2f2a00000
start commit: 56b697c6 Add linux-next specific files for 20190604
git tree: linux-next
final crash: https://syzkaller.appspot.com/x/report.txt?x=1255a2f2a00000
console output: https://syzkaller.appspot.com/x/log.txt?x=1455a2f2a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=4248d6bc70076f7d
dashboard link: https://syzkaller.appspot.com/bug?extid=e1374b2ec8f6a25ab2e5
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=165757eea00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dd3e86a00000
Reported-by: syzbot+e1374b2ec8f6a25ab2e5@syzkaller.appspotmail.com
Fixes: 69d61f577d14 ("ima: verify mprotect change is consistent with mmap
policy")
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
^ permalink raw reply [flat|nested] 4+ messages in thread
* [IMA] Re: possible deadlock in get_user_pages_unlocked (2)
2019-06-05 1:16 ` syzbot
@ 2019-06-10 19:06 ` Eric Biggers
0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2019-06-10 19:06 UTC (permalink / raw)
To: Mimi Zohar
Cc: syzbot, akpm, aneesh.kumar, dan.j.williams, ira.weiny, jack,
jhubbard, jmorris, keith.busch, linux-kernel, linux-mm,
linux-security-module, richard.weiyang, rppt, serge, sfr,
syzkaller-bugs, willy
On Tue, Jun 04, 2019 at 06:16:00PM -0700, syzbot wrote:
> syzbot has bisected this bug to:
>
> commit 69d61f577d147b396be0991b2ac6f65057f7d445
> Author: Mimi Zohar <zohar@linux.ibm.com>
> Date: Wed Apr 3 21:47:46 2019 +0000
>
> ima: verify mprotect change is consistent with mmap policy
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1055a2f2a00000
> start commit: 56b697c6 Add linux-next specific files for 20190604
> git tree: linux-next
> final crash: https://syzkaller.appspot.com/x/report.txt?x=1255a2f2a00000
> console output: https://syzkaller.appspot.com/x/log.txt?x=1455a2f2a00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=4248d6bc70076f7d
> dashboard link: https://syzkaller.appspot.com/bug?extid=e1374b2ec8f6a25ab2e5
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=165757eea00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dd3e86a00000
>
> Reported-by: syzbot+e1374b2ec8f6a25ab2e5@syzkaller.appspotmail.com
> Fixes: 69d61f577d14 ("ima: verify mprotect change is consistent with mmap
> policy")
>
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection
>
Hi Mimi, it seems your change to call ima_file_mmap() from
security_file_mprotect() violates the locking order by taking i_rwsem while
mmap_sem is held.
- Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-10 19:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-01 6:08 possible deadlock in get_user_pages_unlocked (2) syzbot
2019-06-04 21:19 ` syzbot
2019-06-05 1:16 ` syzbot
2019-06-10 19:06 ` [IMA] " Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).