syzbot


possible deadlock in netfs_start_io_direct

Status: upstream: reported on 2024/10/27 15:16
Subsystems: netfs
[Documentation on labels]
Reported-by: syzbot+d0dec022ac98c352d543@syzkaller.appspotmail.com
First crash: 42d, last: 36d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [netfs?] possible deadlock in netfs_start_io_direct 0 (1) 2024/10/27 15:16

Sample crash report:
overlayfs: fs on './file0' does not support file handles, falling back to index=off,nfs_export=off.
======================================================
WARNING: possible circular locking dependency detected
6.12.0-rc5-syzkaller-00005-ge42b1a9a2557 #0 Not tainted
------------------------------------------------------
syz.0.1931/12329 is trying to acquire lock:
ffff88804e4d3b38 (&sb->s_type->i_mutex_key#23){++++}-{3:3}, at: netfs_start_io_direct+0x25/0x260 fs/netfs/locking.c:174

but task is already holding lock:
ffff888025a51498 (&ima_iint_mutex_key[depth]#2){+.+.}-{3:3}, at: process_measurement+0x885/0x2370 security/integrity/ima/ima_main.c:269

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ima_iint_mutex_key[depth]#2){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x175/0x9c0 kernel/locking/mutex.c:752
       process_measurement+0x885/0x2370 security/integrity/ima/ima_main.c:269
       ima_file_mmap+0x1b1/0x1d0 security/integrity/ima/ima_main.c:462
       security_mmap_file+0x8bd/0x990 security/security.c:2979
       __do_sys_remap_file_pages+0x526/0x900 mm/mmap.c:1702
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

-> #1 (&mm->mmap_lock){++++}-{3:3}:
       gup_fast_fallback+0x11f8/0x2690 mm/gup.c:3364
       pin_user_pages_fast+0xa8/0x100 mm/gup.c:3488
       iov_iter_extract_user_pages lib/iov_iter.c:1815 [inline]
       iov_iter_extract_pages+0x397/0x1f30 lib/iov_iter.c:1878
       netfs_extract_user_iter+0x21a/0x620 fs/netfs/iterator.c:67
       netfs_unbuffered_write_iter_locked+0x27d/0xe70 fs/netfs/direct_write.c:71
       netfs_unbuffered_write_iter+0x413/0x6d0 fs/netfs/direct_write.c:193
       v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:404
       do_iter_readv_writev+0x532/0x7f0 fs/read_write.c:834
       vfs_writev+0x363/0xdd0 fs/read_write.c:1064
       do_pwritev+0x1b4/0x270 fs/read_write.c:1165
       __do_compat_sys_pwritev2 fs/read_write.c:1311 [inline]
       __se_compat_sys_pwritev2 fs/read_write.c:1303 [inline]
       __ia32_compat_sys_pwritev2+0x121/0x1b0 fs/read_write.c:1303
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

-> #0 (&sb->s_type->i_mutex_key#23){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain kernel/locking/lockdep.c:3904 [inline]
       __lock_acquire+0x250b/0x3ce0 kernel/locking/lockdep.c:5202
       lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825
       down_read_interruptible+0x9d/0x380 kernel/locking/rwsem.c:1533
       netfs_start_io_direct+0x25/0x260 fs/netfs/locking.c:174
       netfs_unbuffered_read_iter+0xa3/0x100 fs/netfs/direct_read.c:254
       v9fs_file_read_iter+0xbf/0x100 fs/9p/vfs_file.c:361
       do_iter_readv_writev+0x614/0x7f0 fs/read_write.c:832
       vfs_iter_read+0x321/0x480 fs/read_write.c:923
       backing_file_read_iter+0x586/0x780 fs/backing-file.c:183
       ovl_read_iter+0x26c/0x300 fs/overlayfs/file.c:285
       do_iter_readv_writev+0x614/0x7f0 fs/read_write.c:832
       vfs_iter_read+0x321/0x480 fs/read_write.c:923
       backing_file_read_iter+0x586/0x780 fs/backing-file.c:183
       ovl_read_iter+0x26c/0x300 fs/overlayfs/file.c:285
       __kernel_read+0x3f1/0xb50 fs/read_write.c:527
       integrity_kernel_read+0x7f/0xb0 security/integrity/iint.c:28
       ima_calc_file_hash_tfm+0x2c9/0x3e0 security/integrity/ima/ima_crypto.c:480
       ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
       ima_calc_file_hash+0x1ba/0x490 security/integrity/ima/ima_crypto.c:568
       ima_collect_measurement+0x8a7/0xa10 security/integrity/ima/ima_api.c:293
       process_measurement+0x1271/0x2370 security/integrity/ima/ima_main.c:372
       ima_file_check+0xc1/0x110 security/integrity/ima/ima_main.c:572
       security_file_post_open+0x8e/0x210 security/security.c:3129
       do_open fs/namei.c:3776 [inline]
       path_openat+0x1419/0x2d60 fs/namei.c:3933
       do_filp_open+0x1dc/0x430 fs/namei.c:3960
       do_sys_openat2+0x17a/0x1e0 fs/open.c:1415
       do_sys_open fs/open.c:1430 [inline]
       __do_compat_sys_open fs/open.c:1483 [inline]
       __se_compat_sys_open fs/open.c:1481 [inline]
       __ia32_compat_sys_open+0x147/0x1e0 fs/open.c:1481
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

other info that might help us debug this:

Chain exists of:
  &sb->s_type->i_mutex_key#23 --> &mm->mmap_lock --> &ima_iint_mutex_key[depth]#2

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ima_iint_mutex_key[depth]#2);
                               lock(&mm->mmap_lock);
                               lock(&ima_iint_mutex_key[depth]#2);
  rlock(&sb->s_type->i_mutex_key#23);

 *** DEADLOCK ***

1 lock held by syz.0.1931/12329:
 #0: ffff888025a51498 (&ima_iint_mutex_key[depth]#2){+.+.}-{3:3}, at: process_measurement+0x885/0x2370 security/integrity/ima/ima_main.c:269

stack backtrace:
CPU: 0 UID: 0 PID: 12329 Comm: syz.0.1931 Not tainted 6.12.0-rc5-syzkaller-00005-ge42b1a9a2557 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x419/0x5d0 kernel/locking/lockdep.c:2074
 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2206
 check_prev_add kernel/locking/lockdep.c:3161 [inline]
 check_prevs_add kernel/locking/lockdep.c:3280 [inline]
 validate_chain kernel/locking/lockdep.c:3904 [inline]
 __lock_acquire+0x250b/0x3ce0 kernel/locking/lockdep.c:5202
 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825
 down_read_interruptible+0x9d/0x380 kernel/locking/rwsem.c:1533
 netfs_start_io_direct+0x25/0x260 fs/netfs/locking.c:174
 netfs_unbuffered_read_iter+0xa3/0x100 fs/netfs/direct_read.c:254
 v9fs_file_read_iter+0xbf/0x100 fs/9p/vfs_file.c:361
 do_iter_readv_writev+0x614/0x7f0 fs/read_write.c:832
 vfs_iter_read+0x321/0x480 fs/read_write.c:923
 backing_file_read_iter+0x586/0x780 fs/backing-file.c:183
 ovl_read_iter+0x26c/0x300 fs/overlayfs/file.c:285
 do_iter_readv_writev+0x614/0x7f0 fs/read_write.c:832
 vfs_iter_read+0x321/0x480 fs/read_write.c:923
 backing_file_read_iter+0x586/0x780 fs/backing-file.c:183
 ovl_read_iter+0x26c/0x300 fs/overlayfs/file.c:285
 __kernel_read+0x3f1/0xb50 fs/read_write.c:527
 integrity_kernel_read+0x7f/0xb0 security/integrity/iint.c:28
 ima_calc_file_hash_tfm+0x2c9/0x3e0 security/integrity/ima/ima_crypto.c:480
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1ba/0x490 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x8a7/0xa10 security/integrity/ima/ima_api.c:293
 process_measurement+0x1271/0x2370 security/integrity/ima/ima_main.c:372
 ima_file_check+0xc1/0x110 security/integrity/ima/ima_main.c:572
 security_file_post_open+0x8e/0x210 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x1419/0x2d60 fs/namei.c:3933
 do_filp_open+0x1dc/0x430 fs/namei.c:3960
 do_sys_openat2+0x17a/0x1e0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_compat_sys_open fs/open.c:1483 [inline]
 __se_compat_sys_open fs/open.c:1481 [inline]
 __ia32_compat_sys_open+0x147/0x1e0 fs/open.c:1481
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e
RIP: 0023:0xf73ae579
Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:00000000f569655c EFLAGS: 00000296 ORIG_RAX: 0000000000000005
RAX: ffffffffffffffda RBX: 0000000020000500 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
----------------
Code disassembly (best guess), 2 bytes skipped:
   0:	10 06                	adc    %al,(%rsi)
   2:	03 74 b4 01          	add    0x1(%rsp,%rsi,4),%esi
   6:	10 07                	adc    %al,(%rdi)
   8:	03 74 b0 01          	add    0x1(%rax,%rsi,4),%esi
   c:	10 08                	adc    %cl,(%rax)
   e:	03 74 d8 01          	add    0x1(%rax,%rbx,8),%esi
  1e:	00 51 52             	add    %dl,0x52(%rcx)
  21:	55                   	push   %rbp
  22:	89 e5                	mov    %esp,%ebp
  24:	0f 34                	sysenter
  26:	cd 80                	int    $0x80
* 28:	5d                   	pop    %rbp <-- trapping instruction
  29:	5a                   	pop    %rdx
  2a:	59                   	pop    %rcx
  2b:	c3                   	ret
  2c:	90                   	nop
  2d:	90                   	nop
  2e:	90                   	nop
  2f:	90                   	nop
  30:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi
  37:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/29 22:30 upstream e42b1a9a2557 66aeb999 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in netfs_start_io_direct
2024/10/23 15:13 upstream c2ee9f594da8 15fa2979 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in netfs_start_io_direct
* Struck through repros no longer work on HEAD.