possible deadlock in shmem_fallocate (2)

7 views
Skip to first unread message

syzbot

unread,
Mar 10, 2020, 12:27:14 AM3/10/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 7472c402 Linux 4.19.108
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11d41dfde00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6d889e71eea7bde
dashboard link: https://syzkaller.appspot.com/bug?extid=5f45c924884208b0358e
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+5f45c9...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
4.19.108-syzkaller #0 Not tainted
------------------------------------------------------
khugepaged/1087 is trying to acquire lock:
00000000e6f459f8 (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock include/linux/fs.h:747 [inline]
00000000e6f459f8 (&sb->s_type->i_mutex_key#12){+.+.}, at: shmem_fallocate+0x15a/0xd40 mm/shmem.c:2681

but task is already holding lock:
00000000cc980665 (fs_reclaim){+.+.}, at: fs_reclaim_acquire.part.0+0x0/0x30 include/linux/compiler.h:193

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (fs_reclaim){+.+.}:
fs_reclaim_acquire mm/page_alloc.c:4342 [inline]
prepare_alloc_pages mm/page_alloc.c:4339 [inline]
__alloc_pages_nodemask+0x4b7/0x6a0 mm/page_alloc.c:4391
alloc_pages_vma+0xd9/0x580 mm/mempolicy.c:2161
shmem_alloc_page+0xb0/0x170 mm/shmem.c:1494
shmem_alloc_and_acct_page+0x160/0x960 mm/shmem.c:1519
shmem_getpage_gfp+0x3fb/0x3840 mm/shmem.c:1797
shmem_getpage mm/shmem.c:132 [inline]
shmem_write_begin+0x108/0x1e0 mm/shmem.c:2433
generic_perform_write+0x1f8/0x4d0 mm/filemap.c:3162
__generic_file_write_iter+0x24c/0x610 mm/filemap.c:3287
generic_file_write_iter+0x37f/0x729 mm/filemap.c:3315
call_write_iter include/linux/fs.h:1820 [inline]
new_sync_write fs/read_write.c:474 [inline]
__vfs_write+0x512/0x760 fs/read_write.c:487
vfs_write+0x206/0x550 fs/read_write.c:549
ksys_write+0x12b/0x2a0 fs/read_write.c:599
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&sb->s_type->i_mutex_key#12){+.+.}:
down_write+0x34/0x90 kernel/locking/rwsem.c:70
inode_lock include/linux/fs.h:747 [inline]
shmem_fallocate+0x15a/0xd40 mm/shmem.c:2681
ashmem_shrink_scan drivers/staging/android/ashmem.c:489 [inline]
ashmem_shrink_scan+0x34d/0x500 drivers/staging/android/ashmem.c:464
do_shrink_slab+0x3c7/0xa20 mm/vmscan.c:537
batman_adv: Cannot find parent device
shrink_slab mm/vmscan.c:693 [inline]
shrink_slab+0x16f/0x550 mm/vmscan.c:666
shrink_node+0x2e6/0x1350 mm/vmscan.c:2740
shrink_zones mm/vmscan.c:2969 [inline]
do_try_to_free_pages+0x3a3/0x1090 mm/vmscan.c:3027
try_to_free_pages+0x2c5/0x7c0 mm/vmscan.c:3242
__perform_reclaim mm/page_alloc.c:3798 [inline]
__alloc_pages_direct_reclaim mm/page_alloc.c:3819 [inline]
__alloc_pages_slowpath+0x938/0x26a0 mm/page_alloc.c:4209
__alloc_pages_nodemask+0x5b6/0x6a0 mm/page_alloc.c:4417
__alloc_pages include/linux/gfp.h:496 [inline]
__alloc_pages_node include/linux/gfp.h:509 [inline]
khugepaged_alloc_page+0x8e/0x180 mm/khugepaged.c:773
collapse_huge_page+0x114/0x3ba0 mm/khugepaged.c:963
khugepaged_scan_pmd mm/khugepaged.c:1219 [inline]
khugepaged_scan_mm_slot mm/khugepaged.c:1757 [inline]
khugepaged_do_scan mm/khugepaged.c:1838 [inline]
khugepaged+0x2ee9/0x3f70 mm/khugepaged.c:1883
kthread+0x34a/0x420 kernel/kthread.c:246
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&sb->s_type->i_mutex_key#12);
lock(fs_reclaim);
lock(&sb->s_type->i_mutex_key#12);

*** DEADLOCK ***

2 locks held by khugepaged/1087:
#0: 00000000cc980665 (fs_reclaim){+.+.}, at: fs_reclaim_acquire.part.0+0x0/0x30 include/linux/compiler.h:193
#1: 000000002a35732f (shrinker_rwsem){++++}, at: shrink_slab mm/vmscan.c:683 [inline]
#1: 000000002a35732f (shrinker_rwsem){++++}, at: shrink_slab+0xc7/0x550 mm/vmscan.c:666

stack backtrace:
CPU: 0 PID: 1087 Comm: khugepaged Not tainted 4.19.108-syzkaller #0
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+0x188/0x20d lib/dump_stack.c:118
print_circular_bug.isra.0.cold+0x1c4/0x282 kernel/locking/lockdep.c:1221
check_prev_add kernel/locking/lockdep.c:1861 [inline]
check_prevs_add kernel/locking/lockdep.c:1974 [inline]
validate_chain kernel/locking/lockdep.c:2415 [inline]
__lock_acquire+0x2e19/0x49c0 kernel/locking/lockdep.c:3411
lock_acquire+0x170/0x400 kernel/locking/lockdep.c:3903
down_write+0x34/0x90 kernel/locking/rwsem.c:70
inode_lock include/linux/fs.h:747 [inline]
shmem_fallocate+0x15a/0xd40 mm/shmem.c:2681
ashmem_shrink_scan drivers/staging/android/ashmem.c:489 [inline]
ashmem_shrink_scan+0x34d/0x500 drivers/staging/android/ashmem.c:464
do_shrink_slab+0x3c7/0xa20 mm/vmscan.c:537
shrink_slab mm/vmscan.c:693 [inline]
shrink_slab+0x16f/0x550 mm/vmscan.c:666
shrink_node+0x2e6/0x1350 mm/vmscan.c:2740
shrink_zones mm/vmscan.c:2969 [inline]
do_try_to_free_pages+0x3a3/0x1090 mm/vmscan.c:3027
try_to_free_pages+0x2c5/0x7c0 mm/vmscan.c:3242
__perform_reclaim mm/page_alloc.c:3798 [inline]
__alloc_pages_direct_reclaim mm/page_alloc.c:3819 [inline]
__alloc_pages_slowpath+0x938/0x26a0 mm/page_alloc.c:4209
__alloc_pages_nodemask+0x5b6/0x6a0 mm/page_alloc.c:4417
__alloc_pages include/linux/gfp.h:496 [inline]
__alloc_pages_node include/linux/gfp.h:509 [inline]
khugepaged_alloc_page+0x8e/0x180 mm/khugepaged.c:773
collapse_huge_page+0x114/0x3ba0 mm/khugepaged.c:963
khugepaged_scan_pmd mm/khugepaged.c:1219 [inline]
khugepaged_scan_mm_slot mm/khugepaged.c:1757 [inline]
khugepaged_do_scan mm/khugepaged.c:1838 [inline]
khugepaged+0x2ee9/0x3f70 mm/khugepaged.c:1883
kthread+0x34a/0x420 kernel/kthread.c:246
batman_adv: Cannot find parent device
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device
batman_adv: Cannot find parent device


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

unread,
Sep 13, 2020, 10:25:10 PM9/13/20
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages