possible deadlock in ima_file_free

Status: upstream: reported on 2026/11/07 12:48
Reported-by: syzbot+069e65b5229a01c5f82d@syzkaller.appspotmail.com
First crash: 13d, last: 13d
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ima_file_free lsm integrity 4 2 1298d 1296d 0/29 auto-obsoleted due to no activity on 2023/08/23 09:04

Sample crash report:
(syz.2.3,4305,1):__ocfs2_flush_truncate_log:6055 ERROR: status = -30
(syz.2.3,4305,1):ocfs2_try_to_free_truncate_log:6135 ERROR: status = -30
(syz.2.3,4305,1):ocfs2_write_begin_nolock:1878 ERROR: status = -30
(syz.2.3,4305,1):ocfs2_dio_end_io:2448 ERROR: Direct IO failed, bytes = -5
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.2.3/4305 is trying to acquire lock:
ffff88802b56b648 (&iint_mutex_key[depth]){+.+.}-{3:3}, at: ima_check_last_writer security/integrity/ima/ima_main.c:165 [inline]
ffff88802b56b648 (&iint_mutex_key[depth]){+.+.}-{3:3}, at: ima_file_free+0x109/0x3e0 security/integrity/ima/ima_main.c:199

but task is already holding lock:
ffff88805bd04990 (jbd2_handle){++++}-{0:0}, at: start_this_handle+0x12d5/0x1560 fs/jbd2/transaction.c:462

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (jbd2_handle){++++}-{0:0}:
       jbd2_journal_lock_updates+0xa4/0x390 fs/jbd2/transaction.c:881
       __ocfs2_flush_truncate_log+0x2b4/0x1110 fs/ocfs2/alloc.c:6027
       ocfs2_flush_truncate_log fs/ocfs2/alloc.c:6074 [inline]
       ocfs2_try_to_free_truncate_log+0x1a7/0x370 fs/ocfs2/alloc.c:6133
       ocfs2_write_begin_nolock+0x32d6/0x44b0 fs/ocfs2/aops.c:1873
       ocfs2_dio_wr_get_block+0xba4/0x1810 fs/ocfs2/aops.c:2241
       get_more_blocks fs/direct-io.c:673 [inline]
       do_direct_IO fs/direct-io.c:959 [inline]
       do_blockdev_direct_IO fs/direct-io.c:1276 [inline]
       __blockdev_direct_IO+0x142d/0x3b20 fs/direct-io.c:1368
       ocfs2_direct_IO+0x233/0x2a0 fs/ocfs2/aops.c:2488
       generic_file_direct_write+0x222/0x470 mm/filemap.c:3687
       __generic_file_write_iter+0x2b2/0x4e0 mm/filemap.c:3869
       ocfs2_file_write_iter+0x171a/0x1ee0 fs/ocfs2/file.c:2472
       do_iter_readv_writev+0x47d/0x5f0 fs/read_write.c:-1
       do_iter_write+0x1f8/0x7a0 fs/read_write.c:855
       iter_file_splice_write+0x6be/0xcf0 fs/splice.c:689
       do_splice_from fs/splice.c:767 [inline]
       direct_splice_actor+0xe1/0x130 fs/splice.c:956
       splice_direct_to_actor+0x4e8/0xc00 fs/splice.c:902
       do_splice_direct+0x1d4/0x2f0 fs/splice.c:1008
       do_sendfile+0x524/0xe30 fs/read_write.c:1249
       __do_sys_sendfile64 fs/read_write.c:1317 [inline]
       __se_sys_sendfile64+0x141/0x1a0 fs/read_write.c:1303
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #3 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#6){+.+.}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:793 [inline]
       ocfs2_remove_btree_range+0x64f/0x15e0 fs/ocfs2/alloc.c:5742
       ocfs2_commit_truncate+0xb62/0x1d30 fs/ocfs2/alloc.c:7346
       ocfs2_truncate_file+0xd89/0x1540 fs/ocfs2/file.c:505
       ocfs2_setattr+0x1545/0x1b40 fs/ocfs2/file.c:1215
       notify_change+0xbc6/0xee0 fs/attr.c:505
       do_truncate+0x1ac/0x240 fs/open.c:65
       handle_truncate fs/namei.c:3316 [inline]
       do_open fs/namei.c:3663 [inline]
       path_openat+0x293b/0x2fb0 fs/namei.c:3793
       do_filp_open+0x1df/0x400 fs/namei.c:3820
       do_sys_openat2+0x14b/0x500 fs/open.c:1255
       do_sys_open fs/open.c:1271 [inline]
       __do_sys_creat fs/open.c:1347 [inline]
       __se_sys_creat fs/open.c:1341 [inline]
       __x64_sys_creat+0x8c/0xb0 fs/open.c:1341
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #2 (&oi->ip_alloc_sem){++++}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       ocfs2_try_remove_refcount_tree+0xb3/0x360 fs/ocfs2/refcounttree.c:959
       ocfs2_truncate_file+0xe8e/0x1540 fs/ocfs2/file.c:517
       ocfs2_setattr+0x1545/0x1b40 fs/ocfs2/file.c:1215
       notify_change+0xbc6/0xee0 fs/attr.c:505
       do_truncate+0x1ac/0x240 fs/open.c:65
       handle_truncate fs/namei.c:3316 [inline]
       do_open fs/namei.c:3663 [inline]
       path_openat+0x293b/0x2fb0 fs/namei.c:3793
       do_filp_open+0x1df/0x400 fs/namei.c:3820
       do_sys_openat2+0x14b/0x500 fs/open.c:1255
       do_sys_open fs/open.c:1271 [inline]
       __do_sys_openat fs/open.c:1287 [inline]
       __se_sys_openat fs/open.c:1282 [inline]
       __x64_sys_openat+0x135/0x160 fs/open.c:1282
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #1 (&oi->ip_xattr_sem){++++}-{3:3}:
       down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498
       ocfs2_xattr_get+0xf1/0x260 fs/ocfs2/xattr.c:1349
       vfs_getxattr_alloc+0x449/0x5a0 fs/xattr.c:374
       ima_read_xattr+0x35/0x60 security/integrity/ima/ima_appraise.c:226
       process_measurement+0x1001/0x1c20 security/integrity/ima/ima_main.c:333
       ima_file_check+0xc7/0x110 security/integrity/ima/ima_main.c:533
       do_open fs/namei.c:3661 [inline]
       path_openat+0x27cf/0x2fb0 fs/namei.c:3793
       do_filp_open+0x1df/0x400 fs/namei.c:3820
       do_sys_openat2+0x14b/0x500 fs/open.c:1255
       do_sys_open fs/open.c:1271 [inline]
       __do_sys_openat fs/open.c:1287 [inline]
       __se_sys_openat fs/open.c:1282 [inline]
       __x64_sys_openat+0x135/0x160 fs/open.c:1282
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&iint_mutex_key[depth]){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3120 [inline]
       check_prevs_add kernel/locking/lockdep.c:3239 [inline]
       validate_chain kernel/locking/lockdep.c:3855 [inline]
       __lock_acquire+0x38f7/0x7d40 kernel/locking/lockdep.c:5120
       lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5737
       __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       ima_check_last_writer security/integrity/ima/ima_main.c:165 [inline]
       ima_file_free+0x109/0x3e0 security/integrity/ima/ima_main.c:199
       __fput+0x17d/0x8c0 fs/file_table.c:305
       task_work_run+0x125/0x1a0 kernel/task_work.c:188
       get_signal+0x123e/0x12e0 kernel/signal.c:2689
       arch_do_signal_or_restart+0xe6/0x12a0 arch/x86/kernel/signal.c:867
       handle_signal_work kernel/entry/common.c:157 [inline]
       exit_to_user_mode_loop+0x9e/0x130 kernel/entry/common.c:181
       exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:217
       __syscall_exit_to_user_mode_work kernel/entry/common.c:299 [inline]
       syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:310
       do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Chain exists of:
  &iint_mutex_key[depth] --> &ocfs2_sysfile_lock_key[args->fi_sysfile_type]#6 --> jbd2_handle

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(jbd2_handle);
                               lock(&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#6);
                               lock(jbd2_handle);
  lock(&iint_mutex_key[depth]);

 *** DEADLOCK ***

3 locks held by syz.2.3/4305:
 #0: ffff88807b82c650 (sb_internal#2){.+.+}-{0:0}, at: ocfs2_replay_truncate_records fs/ocfs2/alloc.c:5938 [inline]
 #0: ffff88807b82c650 (sb_internal#2){.+.+}-{0:0}, at: __ocfs2_flush_truncate_log+0x49f/0x1110 fs/ocfs2/alloc.c:6052
 #1: ffff88805bc5ace8 (&journal->j_trans_barrier){.+.+}-{3:3}, at: ocfs2_start_trans+0x3a6/0x6f0 fs/ocfs2/journal.c:374
 #2: ffff88805bd04990 (jbd2_handle){++++}-{0:0}, at: start_this_handle+0x12d5/0x1560 fs/jbd2/transaction.c:462

stack backtrace:
CPU: 1 PID: 4305 Comm: syz.2.3 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/15/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
 check_noncircular+0x2f8/0x400 kernel/locking/lockdep.c:2178
 check_prev_add kernel/locking/lockdep.c:3120 [inline]
 check_prevs_add kernel/locking/lockdep.c:3239 [inline]
 validate_chain kernel/locking/lockdep.c:3855 [inline]
 __lock_acquire+0x38f7/0x7d40 kernel/locking/lockdep.c:5120
 lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5737
 __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
 ima_check_last_writer security/integrity/ima/ima_main.c:165 [inline]
 ima_file_free+0x109/0x3e0 security/integrity/ima/ima_main.c:199
 __fput+0x17d/0x8c0 fs/file_table.c:305
 task_work_run+0x125/0x1a0 kernel/task_work.c:188
 get_signal+0x123e/0x12e0 kernel/signal.c:2689
 arch_do_signal_or_restart+0xe6/0x12a0 arch/x86/kernel/signal.c:867
 handle_signal_work kernel/entry/common.c:157 [inline]
 exit_to_user_mode_loop+0x9e/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:217
 __syscall_exit_to_user_mode_work kernel/entry/common.c:299 [inline]
 syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:310
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f4aae0b7b19
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4aac30e028 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: 0000000000590000 RBX: 00007f4aae33dfa0 RCX: 00007f4aae0b7b19
RDX: 0000000000000000 RSI: 000000000000000f RDI: 0000000000000008
RBP: 00007f4aae14fb70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000fffe82 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f4aae33e038 R14: 00007f4aae33dfa0 R15: 00007ffef7b30ae8
 </TASK>
syz.2.3 (4305) used greatest stack depth: 18800 bytes left

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/07 12:48 linux-5.15.y 29c6cdaac04a 5cecaf1f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ima_file_free
* Struck through repros no longer work on HEAD.