[v6.1] possible deadlock in exfat_iterate

0 views
Skip to first unread message

syzbot

unread,
Mar 22, 2023, 12:12:49 PM3/22/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e3a87a10f259 Linux 6.1.21
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17634ff6c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=390800ef8aeebc47
dashboard link: https://syzkaller.appspot.com/bug?extid=e5920f7069574b198c09
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9f5022ccd560/disk-e3a87a10.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f8524664c631/vmlinux-e3a87a10.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ad699b30c2c4/Image-e3a87a10.gz.xz

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

======================================================
WARNING: possible circular locking dependency detected
6.1.21-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/11606 is trying to acquire lock:
ffff0000cab07948 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x9c/0x124 mm/memory.c:5640

but task is already holding lock:
ffff0000d95680e0 (&sbi->s_lock){+.+.}-{3:3}, at: exfat_iterate+0x144/0x2734 fs/exfat/dir.c:228

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sbi->s_lock){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
exfat_get_block+0x164/0x17ec fs/exfat/inode.c:281
do_mpage_readpage+0x5d8/0x1748 fs/mpage.c:208
mpage_readahead+0x360/0x644 fs/mpage.c:361
exfat_readahead+0x28/0x38 fs/exfat/inode.c:344
read_pages+0x168/0x6a0 mm/readahead.c:161
page_cache_ra_unbounded+0x46c/0x58c mm/readahead.c:270
do_page_cache_ra mm/readahead.c:300 [inline]
page_cache_ra_order+0x7fc/0x994 mm/readahead.c:560
ondemand_readahead+0x5f8/0xb04 mm/readahead.c:682
page_cache_sync_ra+0x350/0x3d0 mm/readahead.c:709
page_cache_sync_readahead include/linux/pagemap.h:1213 [inline]
filemap_get_pages mm/filemap.c:2582 [inline]
filemap_read+0x598/0x2260 mm/filemap.c:2676
generic_file_read_iter+0xa0/0x450 mm/filemap.c:2822
__kernel_read+0x30c/0x6b4 fs/read_write.c:428
kernel_read+0xd8/0x1d4 fs/read_write.c:446
prepare_binprm fs/exec.c:1657 [inline]
search_binary_handler fs/exec.c:1711 [inline]
exec_binprm fs/exec.c:1768 [inline]
bprm_execve+0x764/0x162c fs/exec.c:1837
do_execveat_common+0x668/0x814 fs/exec.c:1942
do_execveat fs/exec.c:2027 [inline]
__do_sys_execveat fs/exec.c:2101 [inline]
__se_sys_execveat fs/exec.c:2095 [inline]
__arm64_sys_execveat+0xd0/0xec fs/exec.c:2095
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #1 (mapping.invalidate_lock#3){.+.+}-{3:3}:
down_read+0x5c/0x78 kernel/locking/rwsem.c:1520
filemap_invalidate_lock_shared include/linux/fs.h:811 [inline]
filemap_fault+0x58c/0xf7c mm/filemap.c:3128
__do_fault+0x11c/0x3d8 mm/memory.c:4198
do_read_fault mm/memory.c:4549 [inline]
do_fault mm/memory.c:4678 [inline]
handle_pte_fault mm/memory.c:4950 [inline]
__handle_mm_fault mm/memory.c:5092 [inline]
handle_mm_fault+0x1f20/0x3d18 mm/memory.c:5213
__do_page_fault arch/arm64/mm/fault.c:512 [inline]
do_page_fault+0x634/0xac4 arch/arm64/mm/fault.c:612
do_translation_fault+0x94/0xc8 arch/arm64/mm/fault.c:695
do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:831
el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:367
el1h_64_sync_handler+0x60/0xac arch/arm64/kernel/entry-common.c:427
el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:576
do_strncpy_from_user lib/strncpy_from_user.c:41 [inline]
strncpy_from_user+0x224/0x54c lib/strncpy_from_user.c:139
getname_flags+0x104/0x480 fs/namei.c:150
getname+0x28/0x38 fs/namei.c:218
do_sys_openat2+0xd4/0x3d8 fs/open.c:1304
do_sys_open fs/open.c:1326 [inline]
__do_sys_openat fs/open.c:1342 [inline]
__se_sys_openat fs/open.c:1337 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1337
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (&mm->mmap_lock){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain kernel/locking/lockdep.c:3832 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
__might_fault+0xc4/0x124 mm/memory.c:5641
filldir64+0x2d4/0x948 fs/readdir.c:335
dir_emit_dot include/linux/fs.h:3583 [inline]
dir_emit_dots include/linux/fs.h:3594 [inline]
exfat_iterate+0x23c/0x2734 fs/exfat/dir.c:231
iterate_dir+0x1f4/0x4e4
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64 fs/readdir.c:354 [inline]
__arm64_sys_getdents64+0x1c4/0x4a0 fs/readdir.c:354
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

other info that might help us debug this:

Chain exists of:
&mm->mmap_lock --> mapping.invalidate_lock#3 --> &sbi->s_lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sbi->s_lock);
lock(mapping.invalidate_lock#3);
lock(&sbi->s_lock);
lock(&mm->mmap_lock);

*** DEADLOCK ***

3 locks held by syz-executor.1/11606:
#0: ffff0000db4fc368 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xd8/0x104 fs/file.c:1047
#1: ffff0000df9a5db0 (&sb->s_type->i_mutex_key#21){++++}-{3:3}, at: iterate_dir+0x124/0x4e4 fs/readdir.c:57
#2: ffff0000d95680e0 (&sbi->s_lock){+.+.}-{3:3}, at: exfat_iterate+0x144/0x2734 fs/exfat/dir.c:228

stack backtrace:
CPU: 0 PID: 11606 Comm: syz-executor.1 Not tainted 6.1.21-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x5c lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2056
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain kernel/locking/lockdep.c:3832 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
__might_fault+0xc4/0x124 mm/memory.c:5641
filldir64+0x2d4/0x948 fs/readdir.c:335
dir_emit_dot include/linux/fs.h:3583 [inline]
dir_emit_dots include/linux/fs.h:3594 [inline]
exfat_iterate+0x23c/0x2734 fs/exfat/dir.c:231
iterate_dir+0x1f4/0x4e4
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64 fs/readdir.c:354 [inline]
__arm64_sys_getdents64+0x1c4/0x4a0 fs/readdir.c:354
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Mar 30, 2023, 12:18:45 PM3/30/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c957cbb87315 Linux 5.15.105
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=174c592ec80000
kernel config: https://syzkaller.appspot.com/x/.config?x=852dc3de44ba1f3f
dashboard link: https://syzkaller.appspot.com/bug?extid=fe6b3d2156665345e74e
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/91d0cf1fc5fb/disk-c957cbb8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/346dc1169521/vmlinux-c957cbb8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f7005bdc0e20/Image-c957cbb8.gz.xz

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

exFAT-fs (loop0): failed to load upcase table (idx : 0x00010000, chksum : 0x88ef3d14, utbl_chksum : 0xe619d30d)
======================================================
WARNING: possible circular locking dependency detected
5.15.105-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/9994 is trying to acquire lock:
ffff0000d4840c98 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa0/0x128 mm/memory.c:5296

but task is already holding lock:
ffff0001115ae0e0 (&sbi->s_lock#3){+.+.}-{3:3}, at: exfat_iterate+0x168/0x27a0 fs/exfat/dir.c:229

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sbi->s_lock#3){+.+.}-{3:3}:
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
exfat_get_block+0x16c/0x1b40 fs/exfat/inode.c:303
do_mpage_readpage+0x6f8/0x1c68 fs/mpage.c:231
mpage_readahead+0x35c/0x844 fs/mpage.c:389
exfat_readahead+0x28/0x38 fs/exfat/inode.c:366
read_pages+0x13c/0x420 mm/readahead.c:130
page_cache_ra_unbounded+0x200/0x654 mm/readahead.c:211
do_page_cache_ra mm/readahead.c:269 [inline]
ondemand_readahead+0x62c/0xd0c mm/readahead.c:552
page_cache_sync_ra+0x130/0x180 mm/readahead.c:580
page_cache_sync_readahead include/linux/pagemap.h:833 [inline]
filemap_get_pages mm/filemap.c:2551 [inline]
filemap_read+0x52c/0x1bd4 mm/filemap.c:2634
generic_file_read_iter+0xa0/0x3c4 mm/filemap.c:2785
call_read_iter include/linux/fs.h:2097 [inline]
new_sync_read fs/read_write.c:404 [inline]
vfs_read+0x86c/0xb10 fs/read_write.c:485
ksys_read+0x15c/0x26c fs/read_write.c:623
__do_sys_read fs/read_write.c:633 [inline]
__se_sys_read fs/read_write.c:631 [inline]
__arm64_sys_read+0x7c/0x90 fs/read_write.c:631
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #1 (mapping.invalidate_lock#4){.+.+}-{3:3}:
down_read+0xbc/0x11c kernel/locking/rwsem.c:1488
filemap_invalidate_lock_shared include/linux/fs.h:842 [inline]
filemap_fault+0x52c/0xf5c mm/filemap.c:3072
__do_fault+0x120/0x5d0 mm/memory.c:3871
do_read_fault mm/memory.c:4207 [inline]
do_fault mm/memory.c:4335 [inline]
handle_pte_fault mm/memory.c:4594 [inline]
__handle_mm_fault mm/memory.c:4729 [inline]
handle_mm_fault+0x21ec/0x33c4 mm/memory.c:4827
__do_page_fault arch/arm64/mm/fault.c:505 [inline]
do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605
do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686
do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819
el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:358
el1h_64_sync_handler+0x5c/0x98 arch/arm64/kernel/entry-common.c:409
el1h_64_sync+0x78/0x7c arch/arm64/kernel/entry.S:579
do_strncpy_from_user lib/strncpy_from_user.c:41 [inline]
strncpy_from_user+0x240/0x580 lib/strncpy_from_user.c:139
getname_flags+0x104/0x480 fs/namei.c:149
getname+0x28/0x38 fs/namei.c:217
do_sys_openat2+0xd4/0x3d8 fs/open.c:1205
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1238
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&mm->mmap_lock){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
__might_fault+0xc8/0x128 mm/memory.c:5297
filldir64+0x2bc/0x9e4 fs/readdir.c:335
dir_emit_dot include/linux/fs.h:3605 [inline]
dir_emit_dots include/linux/fs.h:3616 [inline]
exfat_iterate+0x25c/0x27a0 fs/exfat/dir.c:232
iterate_dir+0x1f4/0x4e4
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64 fs/readdir.c:354 [inline]
__arm64_sys_getdents64+0x1c4/0x4c4 fs/readdir.c:354
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Chain exists of:
&mm->mmap_lock --> mapping.invalidate_lock#4 --> &sbi->s_lock#3

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sbi->s_lock#3);
lock(mapping.invalidate_lock#4);
lock(&sbi->s_lock#3);
lock(&mm->mmap_lock);

*** DEADLOCK ***

3 locks held by syz-executor.0/9994:
#0: ffff00010fc2d270 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xdc/0x108 fs/file.c:1073
#1: ffff000110302330 (&sb->s_type->i_mutex_key#23){+.+.}-{3:3}, at: iterate_dir+0x124/0x4e4 fs/readdir.c:57
#2: ffff0001115ae0e0 (&sbi->s_lock#3){+.+.}-{3:3}, at: exfat_iterate+0x168/0x27a0 fs/exfat/dir.c:229

stack backtrace:
CPU: 0 PID: 9994 Comm: syz-executor.0 Not tainted 5.15.105-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
__might_fault+0xc8/0x128 mm/memory.c:5297
filldir64+0x2bc/0x9e4 fs/readdir.c:335
dir_emit_dot include/linux/fs.h:3605 [inline]
dir_emit_dots include/linux/fs.h:3616 [inline]
exfat_iterate+0x25c/0x27a0 fs/exfat/dir.c:232
iterate_dir+0x1f4/0x4e4
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64 fs/readdir.c:354 [inline]
__arm64_sys_getdents64+0x1c4/0x4c4 fs/readdir.c:354
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

syzbot

unread,
May 8, 2023, 5:41:45 AM5/8/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 8a7f2a5c5aa1 Linux 5.15.110
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15954f90280000
kernel config: https://syzkaller.appspot.com/x/.config?x=ba8d5c9d6c5289f
dashboard link: https://syzkaller.appspot.com/bug?extid=fe6b3d2156665345e74e
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17d8c522280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=106fa990280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fc04f54c047f/disk-8a7f2a5c.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/6b4ba4cb1191/vmlinux-8a7f2a5c.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d927dc3f9670/bzImage-8a7f2a5c.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/bc5a5e49aef1/mount_0.gz

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

======================================================
WARNING: possible circular locking dependency detected
5.15.110-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor315/4122 is trying to acquire lock:
ffff88807c355528 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117

but task is already holding lock:
ffff88806fcd00e0 (&sbi->s_lock){+.+.}-{3:3}, at: exfat_iterate+0x197/0x3290 fs/exfat/dir.c:229

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sbi->s_lock){+.+.}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
__mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
exfat_get_block+0x1ca/0x22c0 fs/exfat/inode.c:303
do_mpage_readpage+0x6c8/0x1f70 fs/mpage.c:231
mpage_readahead+0x427/0x9b0 fs/mpage.c:389
read_pages+0x159/0x8e0 mm/readahead.c:130
page_cache_ra_unbounded+0x7b0/0x930 mm/readahead.c:239
page_cache_sync_readahead include/linux/pagemap.h:833 [inline]
filemap_get_pages mm/filemap.c:2551 [inline]
filemap_read+0x71c/0x2980 mm/filemap.c:2634
__kernel_read+0x5ac/0xa60 fs/read_write.c:443
integrity_kernel_read+0xac/0xf0 security/integrity/iint.c:199
ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
ima_calc_file_hash+0xa5d/0x1c00 security/integrity/ima/ima_crypto.c:573
ima_collect_measurement+0x293/0x530 security/integrity/ima/ima_api.c:254
process_measurement+0x1038/0x1d60 security/integrity/ima/ima_main.c:337
ima_file_check+0xf3/0x180 security/integrity/ima/ima_main.c:519
do_open fs/namei.c:3540 [inline]
path_openat+0x2745/0x2f20 fs/namei.c:3672
do_filp_open+0x21c/0x460 fs/namei.c:3699
do_sys_openat2+0x13b/0x500 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1238
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #1 (mapping.invalidate_lock#3){.+.+}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
filemap_invalidate_lock_shared include/linux/fs.h:842 [inline]
filemap_fault+0x708/0x1470 mm/filemap.c:3072
__do_fault+0x139/0x340 mm/memory.c:3885
do_read_fault mm/memory.c:4221 [inline]
do_fault mm/memory.c:4349 [inline]
handle_pte_fault mm/memory.c:4608 [inline]
__handle_mm_fault mm/memory.c:4743 [inline]
handle_mm_fault+0x376f/0x5950 mm/memory.c:4841
do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
handle_page_fault arch/x86/mm/fault.c:1485 [inline]
exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
strncpy_from_user+0x170/0x370 lib/strncpy_from_user.c:139
getname_flags+0xf5/0x4e0 fs/namei.c:149
do_sys_openat2+0xd2/0x500 fs/open.c:1205
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1238
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #0 (&mm->mmap_lock#2){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117
do_user_addr_fault arch/x86/mm/fault.c:1348 [inline]
handle_page_fault arch/x86/mm/fault.c:1485 [inline]
exc_page_fault+0x5ce/0x740 arch/x86/mm/fault.c:1541
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
user_access_begin arch/x86/include/asm/uaccess.h:574 [inline]
filldir64+0x32b/0x730 fs/readdir.c:331
dir_emit_dot include/linux/fs.h:3605 [inline]
dir_emit_dots include/linux/fs.h:3616 [inline]
exfat_iterate+0x2ef/0x3290 fs/exfat/dir.c:232
iterate_dir+0x224/0x570
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

other info that might help us debug this:

Chain exists of:
&mm->mmap_lock#2 --> mapping.invalidate_lock#3 --> &sbi->s_lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sbi->s_lock);
lock(mapping.invalidate_lock#3);
lock(&sbi->s_lock);
lock(&mm->mmap_lock#2);

*** DEADLOCK ***

3 locks held by syz-executor315/4122:
#0: ffff888078ec8870 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x261/0x300 fs/file.c:1073
#1: ffff888070a21cb0 (&sb->s_type->i_mutex_key#15){++++}-{3:3}, at: iterate_dir+0x131/0x570 fs/readdir.c:57
#2: ffff88806fcd00e0 (&sbi->s_lock){+.+.}-{3:3}, at: exfat_iterate+0x197/0x3290 fs/exfat/dir.c:229

stack backtrace:
CPU: 1 PID: 4122 Comm: syz-executor315 Not tainted 5.15.110-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117
do_user_addr_fault arch/x86/mm/fault.c:1348 [inline]
handle_page_fault arch/x86/mm/fault.c:1485 [inline]
exc_page_fault+0x5ce/0x740 arch/x86/mm/fault.c:1541
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
RIP: 0010:filldir64+0x32b/0x730 fs/readdir.c:335
Code: fd 0f 82 60 02 00 00 48 b8 00 f0 ff ff ff 7f 00 00 48 39 c5 0f 87 4d 02 00 00 0f 01 cb 0f ae e8 48 8b 44 24 60 48 8b 4c 24 18 <48> 89 41 08 48 8b 44 24 10 48 8b 4c 24 58 48 89 08 48 8b 4c 24 20
RSP: 0018:ffffc90003bdf740 EFLAGS: 00050287
RAX: 0000000000000000 RBX: 0000000000000018 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000018 RDI: 00007ffffffff000
RBP: 0000000000000018 R08: ffffffff81d9d8ef R09: 0000000000000004
R10: 0000000000000003 R11: ffff88807a533a00 R12: ffffffff8a9e8a20
R13: ffffc90003bdfe70 R14: 0000000000000001 R15: 0000000000000000
dir_emit_dot include/linux/fs.h:3605 [inline]
dir_emit_dots include/linux/fs.h:3616 [inline]
exfat_iterate+0x2ef/0x3290 fs/exfat/dir.c:232
iterate_dir+0x224/0x570
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fe4299f7739
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 18 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe42159a208 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 00007fe429a75798 RCX: 00007fe4299f7739
RDX: 0000000000008008 RSI: 0000000000000000 RDI: 0000000000000006
RBP: 00007fe429a75790 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe429a7579c
R13: 00007ffd02fe1a0f R14: 00007fe42159a300 R15: 0000000000022000
</TASK>
----------------
Code disassembly (best guess):
0: fd std
1: 0f 82 60 02 00 00 jb 0x267
7: 48 b8 00 f0 ff ff ff movabs $0x7ffffffff000,%rax
e: 7f 00 00
11: 48 39 c5 cmp %rax,%rbp
14: 0f 87 4d 02 00 00 ja 0x267
1a: 0f 01 cb stac
1d: 0f ae e8 lfence
20: 48 8b 44 24 60 mov 0x60(%rsp),%rax
25: 48 8b 4c 24 18 mov 0x18(%rsp),%rcx
* 2a: 48 89 41 08 mov %rax,0x8(%rcx) <-- trapping instruction
2e: 48 8b 44 24 10 mov 0x10(%rsp),%rax
33: 48 8b 4c 24 58 mov 0x58(%rsp),%rcx
38: 48 89 08 mov %rcx,(%rax)
3b: 48 8b 4c 24 20 mov 0x20(%rsp),%rcx


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

syzbot

unread,
Oct 6, 2023, 6:45:32 AM10/6/23
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 1c33ca1e197478b315cfe9242648b980dcfd5dbd
Author: Sungjong Seo <sj155...@samsung.com>
Date: Fri Jul 14 08:43:54 2023 +0000

exfat: release s_lock before calling dir_emit()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=14faade1680000
start commit: 8a7f2a5c5aa1 Linux 5.15.110
git tree: linux-5.15.y
If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: exfat: release s_lock before calling dir_emit()

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Oct 18, 2023, 12:53:45 AM10/18/23
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