syzbot


possible deadlock in exc_page_fault

Status: auto-obsoleted due to no activity on 2023/07/25 22:52
Reported-by: syzbot+72297ac5aae77e929e28@syzkaller.appspotmail.com
First crash: 565d, last: 565d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in exc_page_fault exfat C error 100 471d 613d 0/28 auto-obsoleted due to no activity on 2023/09/08 13:51

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.21-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/19479 is trying to acquire lock:
ffff88807ec3d3d8 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:117 [inline]
ffff88807ec3d3d8 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault arch/x86/mm/fault.c:1379 [inline]
ffff88807ec3d3d8 (&mm->mmap_lock#2){++++}-{3:3}, at: handle_page_fault arch/x86/mm/fault.c:1519 [inline]
ffff88807ec3d3d8 (&mm->mmap_lock#2){++++}-{3:3}, at: exc_page_fault+0x46a/0x790 arch/x86/mm/fault.c:1575

but task is already holding lock:
ffff88804617e0e0 (&sbi->s_lock#2){+.+.}-{3:3}, at: exfat_iterate+0x15f/0x3290 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#2){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
       __mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       exfat_get_block+0x1e1/0x2040 fs/exfat/inode.c:281
       do_mpage_readpage+0x8d2/0x2040 fs/mpage.c:208
       mpage_readahead+0x450/0x920 fs/mpage.c:361
       read_pages+0x17f/0x830 mm/readahead.c:161
       page_cache_ra_unbounded+0x68b/0x7b0 mm/readahead.c:270
       page_cache_sync_readahead include/linux/pagemap.h:1213 [inline]
       filemap_get_pages mm/filemap.c:2582 [inline]
       filemap_read+0x7fa/0x31d0 mm/filemap.c:2676
       __kernel_read+0x41e/0x8a0 fs/read_write.c:428
       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+0xa57/0x1c00 security/integrity/ima/ima_crypto.c:573
       ima_collect_measurement+0x4d4/0x970 security/integrity/ima/ima_api.c:292
       process_measurement+0x1018/0x1cf0 security/integrity/ima/ima_main.c:337
       ima_file_check+0xed/0x170 security/integrity/ima/ima_main.c:520
       do_open fs/namei.c:3559 [inline]
       path_openat+0x2687/0x2e60 fs/namei.c:3714
       do_filp_open+0x230/0x480 fs/namei.c:3741
       do_sys_openat2+0x13b/0x500 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_open fs/open.c:1334 [inline]
       __se_sys_open fs/open.c:1330 [inline]
       __x64_sys_open+0x221/0x270 fs/open.c:1330
       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+0x63/0xcd

-> #1 (mapping.invalidate_lock#4){.+.+}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
       down_read+0x39/0x50 kernel/locking/rwsem.c:1520
       filemap_invalidate_lock_shared include/linux/fs.h:811 [inline]
       filemap_fault+0x640/0x17e0 mm/filemap.c:3128
       __do_fault+0x136/0x4f0 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+0x3301/0x5140 mm/memory.c:5213
       do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
       handle_page_fault arch/x86/mm/fault.c:1519 [inline]
       exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
       strncpy_from_user+0x159/0x360 lib/strncpy_from_user.c:139
       getname_flags+0xf5/0x4e0 fs/namei.c:150
       do_sys_openat2+0xd2/0x500 fs/open.c:1304
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_creat fs/open.c:1402 [inline]
       __se_sys_creat fs/open.c:1396 [inline]
       __x64_sys_creat+0x11f/0x160 fs/open.c:1396
       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+0x63/0xcd

-> #0 (&mm->mmap_lock#2){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3098 [inline]
       check_prevs_add kernel/locking/lockdep.c:3217 [inline]
       validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3832
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
       down_read+0x39/0x50 kernel/locking/rwsem.c:1520
       mmap_read_lock include/linux/mmap_lock.h:117 [inline]
       do_user_addr_fault arch/x86/mm/fault.c:1379 [inline]
       handle_page_fault arch/x86/mm/fault.c:1519 [inline]
       exc_page_fault+0x46a/0x790 arch/x86/mm/fault.c:1575
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
       filldir+0x307/0x6f0 fs/readdir.c:249
       dir_emit_dot include/linux/fs.h:3583 [inline]
       dir_emit_dots include/linux/fs.h:3594 [inline]
       exfat_iterate+0x28a/0x3290 fs/exfat/dir.c:231
       iterate_dir+0x224/0x560
       __do_sys_getdents fs/readdir.c:286 [inline]
       __se_sys_getdents+0x1eb/0x4c0 fs/readdir.c:271
       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+0x63/0xcd

other info that might help us debug this:

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

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

3 locks held by syz-executor.0/19479:
 #0: ffff888077c24368 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x250/0x2f0 fs/file.c:1047
 #1: ffff8880493c3d30 (&sb->s_type->i_mutex_key#23){++++}-{3:3}, at: iterate_dir+0x131/0x560 fs/readdir.c:57
 #2: ffff88804617e0e0 (&sbi->s_lock#2){+.+.}-{3:3}, at: exfat_iterate+0x15f/0x3290 fs/exfat/dir.c:228

stack backtrace:
CPU: 1 PID: 19479 Comm: syz-executor.0 Not tainted 6.1.21-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 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+0x1667/0x58e0 kernel/locking/lockdep.c:3832
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
 down_read+0x39/0x50 kernel/locking/rwsem.c:1520
 mmap_read_lock include/linux/mmap_lock.h:117 [inline]
 do_user_addr_fault arch/x86/mm/fault.c:1379 [inline]
 handle_page_fault arch/x86/mm/fault.c:1519 [inline]
 exc_page_fault+0x46a/0x790 arch/x86/mm/fault.c:1575
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:filldir+0x307/0x6f0 fs/readdir.c:253
Code: 48 29 eb 48 89 df 4c 89 e6 e8 85 fb 95 ff 85 ed 0f 88 4e 02 00 00 4c 39 e3 0f 82 45 02 00 00 0f 01 cb 0f ae e8 48 8b 44 24 30 <49> 89 44 24 08 48 8b 4c 24 08 48 8b 44 24 58 48 89 01 48 8b 44 24
RSP: 0018:ffffc90006487768 EFLAGS: 00050206
RAX: 0000000000000000 RBX: 00007fffffffefe8 RCX: ffff8880126b8000
RDX: ffff8880126b8000 RSI: 0000000020001fc0 RDI: 00007fffffffefe8
RBP: 0000000000000018 R08: ffffffff81f38e3b R09: 0000000000000004
R10: 0000000000000003 R11: ffff8880126b8000 R12: 0000000020001fc0
R13: ffffc90006487e70 R14: 0000000000000001 R15: ffffffff8b015a60
 dir_emit_dot include/linux/fs.h:3583 [inline]
 dir_emit_dots include/linux/fs.h:3594 [inline]
 exfat_iterate+0x28a/0x3290 fs/exfat/dir.c:231
 iterate_dir+0x224/0x560
 __do_sys_getdents fs/readdir.c:286 [inline]
 __se_sys_getdents+0x1eb/0x4c0 fs/readdir.c:271
 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+0x63/0xcd
RIP: 0033:0x7f239c68c0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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:00007f2392e1e168 EFLAGS: 00000246 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007f239c7ac050 RCX: 00007f239c68c0f9
RDX: 00000000000000b8 RSI: 0000000020001fc0 RDI: 0000000000000007
RBP: 00007f239c6e7b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffcd074907f R14: 00007f2392e1e300 R15: 0000000000022000
 </TASK>
exFAT-fs (loop0): error, invalid access to FAT (entry 0x00000005) bogus content (0x927a7ff5)
----------------
Code disassembly (best guess):
   0:	48 29 eb             	sub    %rbp,%rbx
   3:	48 89 df             	mov    %rbx,%rdi
   6:	4c 89 e6             	mov    %r12,%rsi
   9:	e8 85 fb 95 ff       	callq  0xff95fb93
   e:	85 ed                	test   %ebp,%ebp
  10:	0f 88 4e 02 00 00    	js     0x264
  16:	4c 39 e3             	cmp    %r12,%rbx
  19:	0f 82 45 02 00 00    	jb     0x264
  1f:	0f 01 cb             	stac
  22:	0f ae e8             	lfence
  25:	48 8b 44 24 30       	mov    0x30(%rsp),%rax
* 2a:	49 89 44 24 08       	mov    %rax,0x8(%r12) <-- trapping instruction
  2f:	48 8b 4c 24 08       	mov    0x8(%rsp),%rcx
  34:	48 8b 44 24 58       	mov    0x58(%rsp),%rax
  39:	48 89 01             	mov    %rax,(%rcx)
  3c:	48                   	rex.W
  3d:	8b                   	.byte 0x8b
  3e:	44                   	rex.R
  3f:	24                   	.byte 0x24

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/27 22:52 linux-6.1.y e3a87a10f259 47f3aaf1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in exc_page_fault
* Struck through repros no longer work on HEAD.