syzbot


possible deadlock in exfat_page_mkwrite

Status: upstream: reported on 2024/04/16 13:14
Subsystems: exfat
[Documentation on labels]
Reported-by: syzbot+d88216a7af9446d57d59@syzkaller.appspotmail.com
First crash: 35d, last: 34d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [exfat?] possible deadlock in exfat_page_mkwrite 2 (3) 2024/04/16 23:38

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.9.0-rc4-next-20240417-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/16103 is trying to acquire lock:
ffff88806400d7a0 (&sb->s_type->i_mutex_key#28){++++}-{3:3}, at: inode_lock include/linux/fs.h:791 [inline]
ffff88806400d7a0 (&sb->s_type->i_mutex_key#28){++++}-{3:3}, at: exfat_page_mkwrite+0x43a/0xea0 fs/exfat/file.c:629

but task is already holding lock:
ffff888065396518 (sb_pagefaults#6){.+.+}-{0:0}, at: do_page_mkwrite+0x19b/0x480 mm/memory.c:3097

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sb_pagefaults#6){.+.+}-{0:0}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1654 [inline]
       sb_start_pagefault include/linux/fs.h:1819 [inline]
       exfat_page_mkwrite+0x161/0xea0 fs/exfat/file.c:619
       do_page_mkwrite+0x19b/0x480 mm/memory.c:3097
       do_shared_fault mm/memory.c:4977 [inline]
       do_fault mm/memory.c:5039 [inline]
       do_pte_missing mm/memory.c:3881 [inline]
       handle_pte_fault+0x1298/0x6dc0 mm/memory.c:5359
       __handle_mm_fault mm/memory.c:5500 [inline]
       handle_mm_fault+0x10e7/0x1bb0 mm/memory.c:5665
       do_user_addr_fault arch/x86/mm/fault.c:1420 [inline]
       handle_page_fault arch/x86/mm/fault.c:1512 [inline]
       exc_page_fault+0x2b9/0x900 arch/x86/mm/fault.c:1570
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623

-> #1 (&mm->mmap_lock){++++}-{3:3}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       gup_fast_fallback+0x24c/0x2b40 mm/gup.c:3442
       pin_user_pages_fast+0xcc/0x160 mm/gup.c:3566
       iov_iter_extract_user_pages lib/iov_iter.c:1583 [inline]
       iov_iter_extract_pages+0x3db/0x720 lib/iov_iter.c:1646
       dio_refill_pages fs/direct-io.c:173 [inline]
       dio_get_page fs/direct-io.c:214 [inline]
       do_direct_IO fs/direct-io.c:916 [inline]
       __blockdev_direct_IO+0x150a/0x49b0 fs/direct-io.c:1249
       blockdev_direct_IO include/linux/fs.h:3183 [inline]
       exfat_direct_IO+0x1b4/0x3d0 fs/exfat/inode.c:526
       generic_file_read_iter+0x231/0x430 mm/filemap.c:2783
       aio_read+0x364/0x500 fs/aio.c:1611
       io_submit_one+0x884/0x18b0 fs/aio.c:2061
       __do_sys_io_submit fs/aio.c:2120 [inline]
       __se_sys_io_submit+0x179/0x2f0 fs/aio.c:2090
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&sb->s_type->i_mutex_key#28){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
       __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       down_write+0x3a/0x50 kernel/locking/rwsem.c:1579
       inode_lock include/linux/fs.h:791 [inline]
       exfat_page_mkwrite+0x43a/0xea0 fs/exfat/file.c:629
       do_page_mkwrite+0x19b/0x480 mm/memory.c:3097
       do_shared_fault mm/memory.c:4977 [inline]
       do_fault mm/memory.c:5039 [inline]
       do_pte_missing mm/memory.c:3881 [inline]
       handle_pte_fault+0x1298/0x6dc0 mm/memory.c:5359
       __handle_mm_fault mm/memory.c:5500 [inline]
       handle_mm_fault+0x10e7/0x1bb0 mm/memory.c:5665
       do_user_addr_fault arch/x86/mm/fault.c:1420 [inline]
       handle_page_fault arch/x86/mm/fault.c:1512 [inline]
       exc_page_fault+0x2b9/0x900 arch/x86/mm/fault.c:1570
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623

other info that might help us debug this:

Chain exists of:
  &sb->s_type->i_mutex_key#28 --> &mm->mmap_lock --> sb_pagefaults#6

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(sb_pagefaults#6);
                               lock(&mm->mmap_lock);
                               lock(sb_pagefaults#6);
  lock(&sb->s_type->i_mutex_key#28);

 *** DEADLOCK ***

2 locks held by syz-executor.1/16103:
 #0: ffff88802d0d6098 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:163 [inline]
 #0: ffff88802d0d6098 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:5692 [inline]
 #0: ffff88802d0d6098 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x32/0x2f0 mm/memory.c:5752
 #1: ffff888065396518 (sb_pagefaults#6){.+.+}-{0:0}, at: do_page_mkwrite+0x19b/0x480 mm/memory.c:3097

stack backtrace:
CPU: 1 PID: 16103 Comm: syz-executor.1 Not tainted 6.9.0-rc4-next-20240417-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
 __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
 down_write+0x3a/0x50 kernel/locking/rwsem.c:1579
 inode_lock include/linux/fs.h:791 [inline]
 exfat_page_mkwrite+0x43a/0xea0 fs/exfat/file.c:629
 do_page_mkwrite+0x19b/0x480 mm/memory.c:3097
 do_shared_fault mm/memory.c:4977 [inline]
 do_fault mm/memory.c:5039 [inline]
 do_pte_missing mm/memory.c:3881 [inline]
 handle_pte_fault+0x1298/0x6dc0 mm/memory.c:5359
 __handle_mm_fault mm/memory.c:5500 [inline]
 handle_mm_fault+0x10e7/0x1bb0 mm/memory.c:5665
 do_user_addr_fault arch/x86/mm/fault.c:1420 [inline]
 handle_page_fault arch/x86/mm/fault.c:1512 [inline]
 exc_page_fault+0x2b9/0x900 arch/x86/mm/fault.c:1570
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0033:0x7fa03fa27006
Code: d0 44 0f b6 52 15 49 c1 e2 34 4c 09 d0 44 0f b6 52 13 0f b6 52 11 49 c1 e2 35 48 c1 e2 36 4c 09 d0 48 09 d0 4c 09 c8 4c 09 c0 <48> 89 04 cf 48 89 04 ce c3 90 48 89 7c 24 f8 48 89 74 24 f0 31 f6
RSP: 002b:00007fa04084b578 EFLAGS: 00010202
RAX: 00008f0000509120 RBX: 000000000000000f RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000020003800 RDI: 0000000020003800
RBP: 0000000020001000 R08: 0000000000009120 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
R13: 00007fa04084ba30 R14: 0000000020000000 R15: 0000000020001800
 </TASK>

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/17 07:15 linux-next 4eab35893071 18f6e127 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in exfat_page_mkwrite
2024/04/17 07:15 linux-next 4eab35893071 18f6e127 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in exfat_page_mkwrite
2024/04/17 07:15 linux-next 4eab35893071 18f6e127 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in exfat_page_mkwrite
2024/04/17 02:00 linux-next 66e4190e92ce 18f6e127 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in exfat_page_mkwrite
2024/04/16 23:27 linux-next 66e4190e92ce 18f6e127 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in exfat_page_mkwrite
2024/04/16 11:49 linux-next 66e4190e92ce 0d592ce4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in exfat_page_mkwrite
* Struck through repros no longer work on HEAD.