syzbot


possible deadlock in hfsplus_block_free

Status: auto-obsoleted due to no activity on 2024/04/14 19:02
Reported-by: syzbot+7e5d4b6e97749bdb6731@syzkaller.appspotmail.com
First crash: 595d, last: 332d
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in hfsplus_block_free (2) 4 178d 178d 0/3 auto-obsoleted due to no activity on 2024/09/15 13:42
linux-4.14 possible deadlock in hfsplus_block_free hfsplus 10 647d 732d 0/1 upstream: reported on 2022/12/01 19:36
linux-4.19 possible deadlock in hfsplus_block_free hfsplus 20 637d 729d 0/1 upstream: reported on 2022/12/04 19:32
upstream possible deadlock in hfsplus_block_free hfs C inconclusive error 257 2d13h 734d 0/28 upstream: reported C repro on 2022/11/29 08:32
linux-5.15 possible deadlock in hfsplus_block_free 20 406d 609d 0/3 auto-obsoleted due to no activity on 2024/01/31 18:41
linux-5.15 possible deadlock in hfsplus_block_free (2) 1 178d 178d 0/3 auto-obsoleted due to no activity on 2024/09/15 11:28

Sample crash report:
loop4: detected capacity change from 0 to 1024
======================================================
WARNING: possible circular locking dependency detected
6.1.55-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/22248 is trying to acquire lock:
ffff88807ad208f8 (&sbi->alloc_mutex){+.+.}-{3:3}, at: hfsplus_block_free+0xb7/0x4d0 fs/hfsplus/bitmap.c:182

but task is already holding lock:
ffff88803fa4d208 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x2d6/0xb40 fs/hfsplus/extents.c:576

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       hfsplus_get_block+0x37f/0x14e0 fs/hfsplus/extents.c:260
       block_read_full_folio+0x403/0xf60 fs/buffer.c:2271
       filemap_read_folio+0x199/0x780 mm/filemap.c:2407
       do_read_cache_folio+0x2ee/0x810 mm/filemap.c:3535
       do_read_cache_page+0x32/0x220 mm/filemap.c:3577
       read_mapping_page include/linux/pagemap.h:756 [inline]
       hfsplus_block_allocate+0xea/0x8b0 fs/hfsplus/bitmap.c:37
       hfsplus_file_extend+0xa4c/0x1b10 fs/hfsplus/extents.c:468
       hfsplus_get_block+0x402/0x14e0 fs/hfsplus/extents.c:245
       __block_write_begin_int+0x544/0x1a30 fs/buffer.c:1991
       __block_write_begin fs/buffer.c:2041 [inline]
       block_write_begin+0x98/0x1f0 fs/buffer.c:2102
       cont_write_begin+0x63f/0x880 fs/buffer.c:2456
       hfsplus_write_begin+0x86/0xd0 fs/hfsplus/inode.c:52
       generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3754
       __generic_file_write_iter+0x176/0x400 mm/filemap.c:3882
       generic_file_write_iter+0xab/0x310 mm/filemap.c:3914
       call_write_iter include/linux/fs.h:2205 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x7ae/0xba0 fs/read_write.c:584
       ksys_write+0x19c/0x2c0 fs/read_write.c:637
       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 (&sbi->alloc_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3824
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       hfsplus_block_free+0xb7/0x4d0 fs/hfsplus/bitmap.c:182
       hfsplus_free_extents+0x17a/0xae0 fs/hfsplus/extents.c:363
       hfsplus_file_truncate+0x7cc/0xb40 fs/hfsplus/extents.c:591
       hfsplus_setattr+0x1b9/0x280 fs/hfsplus/inode.c:269
       notify_change+0xce3/0xfc0 fs/attr.c:499
       do_truncate+0x21c/0x300 fs/open.c:65
       handle_truncate fs/namei.c:3216 [inline]
       do_open fs/namei.c:3561 [inline]
       path_openat+0x27e2/0x2e60 fs/namei.c:3714
       do_filp_open+0x230/0x480 fs/namei.c:3741
       do_sys_openat2+0x13b/0x500 fs/open.c:1318
       do_sys_open fs/open.c:1334 [inline]
       __do_sys_creat fs/open.c:1410 [inline]
       __se_sys_creat fs/open.c:1404 [inline]
       __x64_sys_creat+0x11f/0x160 fs/open.c:1404
       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:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&HFSPLUS_I(inode)->extents_lock);
                               lock(&sbi->alloc_mutex);
                               lock(&HFSPLUS_I(inode)->extents_lock);
  lock(&sbi->alloc_mutex);

 *** DEADLOCK ***

3 locks held by syz-executor.4/22248:
 #0: ffff888079080460 (sb_writers#21){.+.+}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:393
 #1: ffff88803fa4d400 (&sb->s_type->i_mutex_key#36){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff88803fa4d400 (&sb->s_type->i_mutex_key#36){+.+.}-{3:3}, at: do_truncate+0x208/0x300 fs/open.c:63
 #2: ffff88803fa4d208 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x2d6/0xb40 fs/hfsplus/extents.c:576

stack backtrace:
CPU: 0 PID: 22248 Comm: syz-executor.4 Not tainted 6.1.55-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/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:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3824
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
 hfsplus_block_free+0xb7/0x4d0 fs/hfsplus/bitmap.c:182
 hfsplus_free_extents+0x17a/0xae0 fs/hfsplus/extents.c:363
 hfsplus_file_truncate+0x7cc/0xb40 fs/hfsplus/extents.c:591
 hfsplus_setattr+0x1b9/0x280 fs/hfsplus/inode.c:269
 notify_change+0xce3/0xfc0 fs/attr.c:499
 do_truncate+0x21c/0x300 fs/open.c:65
 handle_truncate fs/namei.c:3216 [inline]
 do_open fs/namei.c:3561 [inline]
 path_openat+0x27e2/0x2e60 fs/namei.c:3714
 do_filp_open+0x230/0x480 fs/namei.c:3741
 do_sys_openat2+0x13b/0x500 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_creat fs/open.c:1410 [inline]
 __se_sys_creat fs/open.c:1404 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1404
 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:0x7fadccc7cae9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fadcdac60c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007fadccd9bf80 RCX: 00007fadccc7cae9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000080
RBP: 00007fadcccc847a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fadccd9bf80 R15: 00007ffe51ba4178
 </TASK>

Crashes (27):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/09/28 08:50 linux-6.1.y d23900f974e0 c2ab1e5d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/09/28 01:07 linux-6.1.y d23900f974e0 2895a507 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/09/12 19:02 linux-6.1.y 59b13c2b647e 59da8366 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2024/01/05 19:01 linux-6.1.y 38fb82ecd144 28c42cff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/11/27 21:15 linux-6.1.y 69e434a1cb21 7ec6c044 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/10/29 01:10 linux-6.1.y 32c9cdbe383c 3c418d72 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/10/13 00:21 linux-6.1.y 082280fe94a0 6388bc36 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/10/09 18:40 linux-6.1.y ecda77b46871 3c53c7d9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/10/06 19:23 linux-6.1.y ecda77b46871 ea12a918 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/09/27 15:02 linux-6.1.y d23900f974e0 2895a507 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/09/13 10:15 linux-6.1.y 09045dae0d90 0b6a67ac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/07/24 03:40 linux-6.1.y 75389113731b 27cbe77f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/07/18 18:48 linux-6.1.y 61fd484b2cf6 022df2bb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/07/07 07:51 linux-6.1.y 61fd484b2cf6 22ae5830 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/06/15 19:11 linux-6.1.y ca87e77a2ef8 90d4044e .config console log report info ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/06/01 14:44 linux-6.1.y d2869ace6eeb babc4389 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/06/01 03:43 linux-6.1.y d2869ace6eeb babc4389 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/04/16 21:54 linux-6.1.y 0102425ac76b ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfsplus_block_free
2023/08/19 02:54 linux-6.1.y 6c44e13dc284 d216d8a0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/08/18 14:17 linux-6.1.y 6c44e13dc284 acb1ba71 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/07/23 21:17 linux-6.1.y 75389113731b 27cbe77f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/04/25 05:40 linux-6.1.y f17b0ab65d17 65320f8e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/04/24 14:07 linux-6.1.y f17b0ab65d17 fdc18293 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/04/23 15:13 linux-6.1.y f17b0ab65d17 2b32bd34 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/04/21 03:15 linux-6.1.y f17b0ab65d17 2b32bd34 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/04/18 14:57 linux-6.1.y 0102425ac76b d931e9f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
2023/04/17 13:59 linux-6.1.y 0102425ac76b c6ec7083 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfsplus_block_free
* Struck through repros no longer work on HEAD.