All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct
@ 2025-05-08 16:22 syzbot
  2025-05-08 16:37 ` Ryusuke Konishi
  2025-05-09 13:29 ` Edward Adam Davis
  0 siblings, 2 replies; 6+ messages in thread
From: syzbot @ 2025-05-08 16:22 UTC (permalink / raw)
  To: konishi.ryusuke, linux-kernel, linux-nilfs, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    e8ab83e34bdc Merge tag 'arm64-fixes' of git://git.kernel.o..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=146e70f4580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a9a25b7a36123454
dashboard link: https://syzkaller.appspot.com/bug?extid=81394db39b0e2ed2db06
compiler:       Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=148c9a70580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1530b8d4580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-e8ab83e3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b26f15c51ac7/vmlinux-e8ab83e3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/05e91bf788d8/bzImage-e8ab83e3.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/09efd3b532ea/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+81394db39b0e2ed2db06@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.15.0-rc4-syzkaller-00296-ge8ab83e34bdc #0 Not tainted
------------------------------------------------------
segctord/5299 is trying to acquire lock:
ffff88801189e090 (&nilfs->ns_sem){++++}-{4:4}, at: nilfs_segctor_construct+0x2b1/0x690 fs/nilfs2/segment.c:2485

but task is already holding lock:
ffff88801189e2a0 (&nilfs->ns_segctor_sem){++++}-{4:4}, at: nilfs_transaction_lock+0x253/0x4c0 fs/nilfs2/segment.c:357

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&nilfs->ns_segctor_sem){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
       nilfs_transaction_begin+0x365/0x710 fs/nilfs2/segment.c:221
       nilfs_create+0xc9/0x2f0 fs/nilfs2/namei.c:95
       lookup_open fs/namei.c:3701 [inline]
       open_last_lookups fs/namei.c:3800 [inline]
       path_openat+0x14f1/0x3830 fs/namei.c:4036
       do_filp_open+0x1fa/0x410 fs/namei.c:4066
       do_sys_openat2+0x121/0x1c0 fs/open.c:1429
       do_sys_open fs/open.c:1444 [inline]
       __do_sys_openat fs/open.c:1460 [inline]
       __se_sys_openat fs/open.c:1455 [inline]
       __x64_sys_openat+0x138/0x170 fs/open.c:1455
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #4 (sb_internal#2){.+.+}-{0:0}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
       __sb_start_write include/linux/fs.h:1783 [inline]
       sb_start_intwrite include/linux/fs.h:1966 [inline]
       nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
       nilfs_page_mkwrite+0x8b0/0xc20 fs/nilfs2/file.c:95
       do_page_mkwrite+0x14a/0x310 mm/memory.c:3287
       do_shared_fault mm/memory.c:5594 [inline]
       do_fault mm/memory.c:5656 [inline]
       do_pte_missing mm/memory.c:4160 [inline]
       handle_pte_fault mm/memory.c:5997 [inline]
       __handle_mm_fault+0x18d2/0x5380 mm/memory.c:6140
       handle_mm_fault+0x3f6/0x8c0 mm/memory.c:6309
       do_user_addr_fault+0x764/0x1390 arch/x86/mm/fault.c:1388
       handle_page_fault arch/x86/mm/fault.c:1480 [inline]
       exc_page_fault+0x68/0x110 arch/x86/mm/fault.c:1538
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623

-> #3 (sb_pagefaults){.+.+}-{0:0}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
       __sb_start_write include/linux/fs.h:1783 [inline]
       sb_start_pagefault include/linux/fs.h:1948 [inline]
       nilfs_page_mkwrite+0x21e/0xc20 fs/nilfs2/file.c:57
       do_page_mkwrite+0x14a/0x310 mm/memory.c:3287
       do_shared_fault mm/memory.c:5594 [inline]
       do_fault mm/memory.c:5656 [inline]
       do_pte_missing mm/memory.c:4160 [inline]
       handle_pte_fault mm/memory.c:5997 [inline]
       __handle_mm_fault+0x18d2/0x5380 mm/memory.c:6140
       handle_mm_fault+0x3f6/0x8c0 mm/memory.c:6309
       do_user_addr_fault+0x764/0x1390 arch/x86/mm/fault.c:1388
       handle_page_fault arch/x86/mm/fault.c:1480 [inline]
       exc_page_fault+0x68/0x110 arch/x86/mm/fault.c:1538
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623

-> #2 (&mm->mmap_lock){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       __might_fault+0xcc/0x130 mm/memory.c:7151
       _copy_to_iter+0xf3/0x15a0 lib/iov_iter.c:184
       copy_page_to_iter+0xa7/0x150 lib/iov_iter.c:362
       copy_folio_to_iter include/linux/uio.h:198 [inline]
       filemap_read+0x78d/0x11d0 mm/filemap.c:2753
       blkdev_read_iter+0x30a/0x440 block/fops.c:809
       new_sync_read fs/read_write.c:489 [inline]
       vfs_read+0x4cd/0x980 fs/read_write.c:570
       ksys_read+0x145/0x250 fs/read_write.c:713
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&sb->s_type->i_mutex_key#8){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
       inode_lock include/linux/fs.h:867 [inline]
       set_blocksize+0x23b/0x500 block/bdev.c:203
       sb_set_blocksize block/bdev.c:224 [inline]
       sb_min_blocksize+0x119/0x210 block/bdev.c:239
       init_nilfs+0x43/0x690 fs/nilfs2/the_nilfs.c:710
       nilfs_fill_super+0x8f/0x650 fs/nilfs2/super.c:1060
       nilfs_get_tree+0x4f4/0x870 fs/nilfs2/super.c:1228
       vfs_get_tree+0x8f/0x2b0 fs/super.c:1759
       do_new_mount+0x24a/0xa40 fs/namespace.c:3884
       do_mount fs/namespace.c:4224 [inline]
       __do_sys_mount fs/namespace.c:4435 [inline]
       __se_sys_mount+0x317/0x410 fs/namespace.c:4412
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&nilfs->ns_sem){++++}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3166 [inline]
       check_prevs_add kernel/locking/lockdep.c:3285 [inline]
       validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
       __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
       nilfs_segctor_construct+0x2b1/0x690 fs/nilfs2/segment.c:2485
       nilfs_segctor_thread_construct fs/nilfs2/segment.c:2586 [inline]
       nilfs_segctor_thread+0x6f7/0xe00 fs/nilfs2/segment.c:2700
       kthread+0x70e/0x8a0 kernel/kthread.c:464
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

other info that might help us debug this:

Chain exists of:
  &nilfs->ns_sem --> sb_internal#2 --> &nilfs->ns_segctor_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&nilfs->ns_segctor_sem);
                               lock(sb_internal#2);
                               lock(&nilfs->ns_segctor_sem);
  lock(&nilfs->ns_sem);

 *** DEADLOCK ***

1 lock held by segctord/5299:
 #0: ffff88801189e2a0 (&nilfs->ns_segctor_sem){++++}-{4:4}, at: nilfs_transaction_lock+0x253/0x4c0 fs/nilfs2/segment.c:357

stack backtrace:
CPU: 0 UID: 0 PID: 5299 Comm: segctord Not tainted 6.15.0-rc4-syzkaller-00296-ge8ab83e34bdc #0 PREEMPT(full) 
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_lvl+0x189/0x250 lib/dump_stack.c:120
 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2079
 check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2211
 check_prev_add kernel/locking/lockdep.c:3166 [inline]
 check_prevs_add kernel/locking/lockdep.c:3285 [inline]
 validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
 __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
 down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
 nilfs_segctor_construct+0x2b1/0x690 fs/nilfs2/segment.c:2485
 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2586 [inline]
 nilfs_segctor_thread+0x6f7/0xe00 fs/nilfs2/segment.c:2700
 kthread+0x70e/0x8a0 kernel/kthread.c:464
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct
  2025-05-08 16:22 [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct syzbot
@ 2025-05-08 16:37 ` Ryusuke Konishi
  2025-05-09 13:29 ` Edward Adam Davis
  1 sibling, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2025-05-08 16:37 UTC (permalink / raw)
  To: syzbot; +Cc: linux-kernel, linux-nilfs, syzkaller-bugs

On Fri, May 9, 2025 at 1:22 AM syzbot
<syzbot+81394db39b0e2ed2db06@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit:    e8ab83e34bdc Merge tag 'arm64-fixes' of git://git.kernel.o..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=146e70f4580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=a9a25b7a36123454
> dashboard link: https://syzkaller.appspot.com/bug?extid=81394db39b0e2ed2db06
> compiler:       Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=148c9a70580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1530b8d4580000
>
> Downloadable assets:
> disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-e8ab83e3.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/b26f15c51ac7/vmlinux-e8ab83e3.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/05e91bf788d8/bzImage-e8ab83e3.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/09efd3b532ea/mount_0.gz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+81394db39b0e2ed2db06@syzkaller.appspotmail.com
>
> ======================================================
> WARNING: possible circular locking dependency detected
> 6.15.0-rc4-syzkaller-00296-ge8ab83e34bdc #0 Not tainted
> ------------------------------------------------------
> segctord/5299 is trying to acquire lock:
> ffff88801189e090 (&nilfs->ns_sem){++++}-{4:4}, at: nilfs_segctor_construct+0x2b1/0x690 fs/nilfs2/segment.c:2485
>
> but task is already holding lock:
> ffff88801189e2a0 (&nilfs->ns_segctor_sem){++++}-{4:4}, at: nilfs_transaction_lock+0x253/0x4c0 fs/nilfs2/segment.c:357
>
> which lock already depends on the new lock.
>
>
> the existing dependency chain (in reverse order) is:
>
> -> #5 (&nilfs->ns_segctor_sem){++++}-{4:4}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
>        nilfs_transaction_begin+0x365/0x710 fs/nilfs2/segment.c:221
>        nilfs_create+0xc9/0x2f0 fs/nilfs2/namei.c:95
>        lookup_open fs/namei.c:3701 [inline]
>        open_last_lookups fs/namei.c:3800 [inline]
>        path_openat+0x14f1/0x3830 fs/namei.c:4036
>        do_filp_open+0x1fa/0x410 fs/namei.c:4066
>        do_sys_openat2+0x121/0x1c0 fs/open.c:1429
>        do_sys_open fs/open.c:1444 [inline]
>        __do_sys_openat fs/open.c:1460 [inline]
>        __se_sys_openat fs/open.c:1455 [inline]
>        __x64_sys_openat+0x138/0x170 fs/open.c:1455
>        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
>        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
>        entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> -> #4 (sb_internal#2){.+.+}-{0:0}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
>        __sb_start_write include/linux/fs.h:1783 [inline]
>        sb_start_intwrite include/linux/fs.h:1966 [inline]
>        nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
>        nilfs_page_mkwrite+0x8b0/0xc20 fs/nilfs2/file.c:95
>        do_page_mkwrite+0x14a/0x310 mm/memory.c:3287
>        do_shared_fault mm/memory.c:5594 [inline]
>        do_fault mm/memory.c:5656 [inline]
>        do_pte_missing mm/memory.c:4160 [inline]
>        handle_pte_fault mm/memory.c:5997 [inline]
>        __handle_mm_fault+0x18d2/0x5380 mm/memory.c:6140
>        handle_mm_fault+0x3f6/0x8c0 mm/memory.c:6309
>        do_user_addr_fault+0x764/0x1390 arch/x86/mm/fault.c:1388
>        handle_page_fault arch/x86/mm/fault.c:1480 [inline]
>        exc_page_fault+0x68/0x110 arch/x86/mm/fault.c:1538
>        asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
>
> -> #3 (sb_pagefaults){.+.+}-{0:0}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
>        __sb_start_write include/linux/fs.h:1783 [inline]
>        sb_start_pagefault include/linux/fs.h:1948 [inline]
>        nilfs_page_mkwrite+0x21e/0xc20 fs/nilfs2/file.c:57
>        do_page_mkwrite+0x14a/0x310 mm/memory.c:3287
>        do_shared_fault mm/memory.c:5594 [inline]
>        do_fault mm/memory.c:5656 [inline]
>        do_pte_missing mm/memory.c:4160 [inline]
>        handle_pte_fault mm/memory.c:5997 [inline]
>        __handle_mm_fault+0x18d2/0x5380 mm/memory.c:6140
>        handle_mm_fault+0x3f6/0x8c0 mm/memory.c:6309
>        do_user_addr_fault+0x764/0x1390 arch/x86/mm/fault.c:1388
>        handle_page_fault arch/x86/mm/fault.c:1480 [inline]
>        exc_page_fault+0x68/0x110 arch/x86/mm/fault.c:1538
>        asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
>
> -> #2 (&mm->mmap_lock){++++}-{4:4}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        __might_fault+0xcc/0x130 mm/memory.c:7151
>        _copy_to_iter+0xf3/0x15a0 lib/iov_iter.c:184
>        copy_page_to_iter+0xa7/0x150 lib/iov_iter.c:362
>        copy_folio_to_iter include/linux/uio.h:198 [inline]
>        filemap_read+0x78d/0x11d0 mm/filemap.c:2753
>        blkdev_read_iter+0x30a/0x440 block/fops.c:809
>        new_sync_read fs/read_write.c:489 [inline]
>        vfs_read+0x4cd/0x980 fs/read_write.c:570
>        ksys_read+0x145/0x250 fs/read_write.c:713
>        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
>        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
>        entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> -> #1 (&sb->s_type->i_mutex_key#8){++++}-{4:4}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
>        inode_lock include/linux/fs.h:867 [inline]
>        set_blocksize+0x23b/0x500 block/bdev.c:203
>        sb_set_blocksize block/bdev.c:224 [inline]
>        sb_min_blocksize+0x119/0x210 block/bdev.c:239
>        init_nilfs+0x43/0x690 fs/nilfs2/the_nilfs.c:710
>        nilfs_fill_super+0x8f/0x650 fs/nilfs2/super.c:1060
>        nilfs_get_tree+0x4f4/0x870 fs/nilfs2/super.c:1228
>        vfs_get_tree+0x8f/0x2b0 fs/super.c:1759
>        do_new_mount+0x24a/0xa40 fs/namespace.c:3884
>        do_mount fs/namespace.c:4224 [inline]
>        __do_sys_mount fs/namespace.c:4435 [inline]
>        __se_sys_mount+0x317/0x410 fs/namespace.c:4412
>        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
>        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
>        entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> -> #0 (&nilfs->ns_sem){++++}-{4:4}:
>        check_prev_add kernel/locking/lockdep.c:3166 [inline]
>        check_prevs_add kernel/locking/lockdep.c:3285 [inline]
>        validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
>        __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
>        nilfs_segctor_construct+0x2b1/0x690 fs/nilfs2/segment.c:2485
>        nilfs_segctor_thread_construct fs/nilfs2/segment.c:2586 [inline]
>        nilfs_segctor_thread+0x6f7/0xe00 fs/nilfs2/segment.c:2700
>        kthread+0x70e/0x8a0 kernel/kthread.c:464
>        ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
>        ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
>
> other info that might help us debug this:
>
> Chain exists of:
>   &nilfs->ns_sem --> sb_internal#2 --> &nilfs->ns_segctor_sem
>
>  Possible unsafe locking scenario:
>
>        CPU0                    CPU1
>        ----                    ----
>   lock(&nilfs->ns_segctor_sem);
>                                lock(sb_internal#2);
>                                lock(&nilfs->ns_segctor_sem);
>   lock(&nilfs->ns_sem);
>
>  *** DEADLOCK ***
>
> 1 lock held by segctord/5299:
>  #0: ffff88801189e2a0 (&nilfs->ns_segctor_sem){++++}-{4:4}, at: nilfs_transaction_lock+0x253/0x4c0 fs/nilfs2/segment.c:357
>
> stack backtrace:
> CPU: 0 UID: 0 PID: 5299 Comm: segctord Not tainted 6.15.0-rc4-syzkaller-00296-ge8ab83e34bdc #0 PREEMPT(full)
> 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_lvl+0x189/0x250 lib/dump_stack.c:120
>  print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2079
>  check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2211
>  check_prev_add kernel/locking/lockdep.c:3166 [inline]
>  check_prevs_add kernel/locking/lockdep.c:3285 [inline]
>  validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
>  __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
>  lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>  down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
>  nilfs_segctor_construct+0x2b1/0x690 fs/nilfs2/segment.c:2485
>  nilfs_segctor_thread_construct fs/nilfs2/segment.c:2586 [inline]
>  nilfs_segctor_thread+0x6f7/0xe00 fs/nilfs2/segment.c:2700
>  kthread+0x70e/0x8a0 kernel/kthread.c:464
>  ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
>  ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
>  </TASK>
>
>
> ---
> This report is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> If the report is already addressed, let syzbot know by replying with:
> #syz fix: exact-commit-title
>
> If you want syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
>
> If you want to overwrite report's subsystems, reply with:
> #syz set subsystems: new-subsystem
> (See the list of subsystem names on the web dashboard)
>
> If the report is a duplicate of another one, reply with:
> #syz dup: exact-subject-of-another-report
>
> If you want to undo deduplication, reply with:
> #syz undup

This looks a false positive deadlock warning similar to the one in the
syzbot report
below, caused by inode locking introduced in set_blocksize():

#syz dup: possible deadlock in __nilfs_error (3)

A patch to fix this warning is already on its way to the mainline.

Ryusuke Konishi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct
  2025-05-08 16:22 [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct syzbot
  2025-05-08 16:37 ` Ryusuke Konishi
@ 2025-05-09 13:29 ` Edward Adam Davis
  2025-05-09 13:46   ` syzbot
  1 sibling, 1 reply; 6+ messages in thread
From: Edward Adam Davis @ 2025-05-09 13:29 UTC (permalink / raw)
  To: syzbot+81394db39b0e2ed2db06; +Cc: linux-kernel, syzkaller-bugs

#syz test

diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 83970d97840b..d3076015771f 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2582,8 +2582,8 @@ static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode)
 {
 	struct nilfs_transaction_info ti;
 
-	nilfs_transaction_lock(sci->sc_super, &ti, 0);
 	nilfs_segctor_construct(sci, mode);
+	nilfs_transaction_lock(sci->sc_super, &ti, 0);
 
 	/*
 	 * Unclosed segment should be retried.  We do this using sc_timer.


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct
  2025-05-09 13:29 ` Edward Adam Davis
@ 2025-05-09 13:46   ` syzbot
  2025-05-10 13:31     ` Ryusuke Konishi
  0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2025-05-09 13:46 UTC (permalink / raw)
  To: eadavis, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in nilfs_mdt_get_block

======================================================
WARNING: possible circular locking dependency detected
6.15.0-rc5-syzkaller-00136-g9c69f8884904-dirty #0 Not tainted
------------------------------------------------------
segctord/5927 is trying to acquire lock:
ffff88803ffcc610 (sb_internal#2){.+.+}-{0:0}, at: nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
ffff88803ffcc610 (sb_internal#2){.+.+}-{0:0}, at: nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258

but task is already holding lock:
ffff8880422660a0 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}, at: nilfs_bmap_propagate+0x2f/0x130 fs/nilfs2/bmap.c:328

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
       nilfs_bmap_lookup_at_level+0x92/0x3d0 fs/nilfs2/bmap.c:65
       nilfs_bmap_lookup fs/nilfs2/bmap.h:182 [inline]
       nilfs_mdt_submit_block+0x3a3/0x830 fs/nilfs2/mdt.c:144
       nilfs_mdt_read_block+0x46/0x320 fs/nilfs2/mdt.c:178
       nilfs_mdt_get_block+0x11f/0xab0 fs/nilfs2/mdt.c:254
       nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
       nilfs_palloc_get_desc_block fs/nilfs2/alloc.c:296 [inline]
       nilfs_palloc_prepare_alloc_entry+0x3a3/0xf40 fs/nilfs2/alloc.c:607
       nilfs_ifile_create_inode+0x111/0x2e0 fs/nilfs2/ifile.c:61
       nilfs_new_inode+0x1ed/0x750 fs/nilfs2/inode.c:321
       nilfs_create+0x100/0x2f0 fs/nilfs2/namei.c:98
       lookup_open fs/namei.c:3701 [inline]
       open_last_lookups fs/namei.c:3800 [inline]
       path_openat+0x14f1/0x3830 fs/namei.c:4036
       do_filp_open+0x1fa/0x410 fs/namei.c:4066
       do_sys_openat2+0x121/0x1c0 fs/open.c:1429
       do_sys_open fs/open.c:1444 [inline]
       __do_sys_openat fs/open.c:1460 [inline]
       __se_sys_openat fs/open.c:1455 [inline]
       __x64_sys_openat+0x138/0x170 fs/open.c:1455
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&nilfs->ns_segctor_sem){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
       nilfs_transaction_begin+0x365/0x710 fs/nilfs2/segment.c:221
       nilfs_create+0xc9/0x2f0 fs/nilfs2/namei.c:95
       lookup_open fs/namei.c:3701 [inline]
       open_last_lookups fs/namei.c:3800 [inline]
       path_openat+0x14f1/0x3830 fs/namei.c:4036
       do_filp_open+0x1fa/0x410 fs/namei.c:4066
       do_sys_openat2+0x121/0x1c0 fs/open.c:1429
       do_sys_open fs/open.c:1444 [inline]
       __do_sys_openat fs/open.c:1460 [inline]
       __se_sys_openat fs/open.c:1455 [inline]
       __x64_sys_openat+0x138/0x170 fs/open.c:1455
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (sb_internal#2){.+.+}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3166 [inline]
       check_prevs_add kernel/locking/lockdep.c:3285 [inline]
       validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
       __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
       __sb_start_write include/linux/fs.h:1783 [inline]
       sb_start_intwrite include/linux/fs.h:1966 [inline]
       nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
       nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
       nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
       nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
       nilfs_palloc_get_entry_block+0x8c/0xa0 fs/nilfs2/alloc.c:355
       nilfs_dat_prepare_entry fs/nilfs2/dat.c:45 [inline]
       nilfs_dat_prepare_alloc fs/nilfs2/dat.c:82 [inline]
       nilfs_dat_prepare_update+0xb1/0x300 fs/nilfs2/dat.c:250
       nilfs_direct_propagate+0x1ac/0x370 fs/nilfs2/direct.c:279
       nilfs_bmap_propagate+0x77/0x130 fs/nilfs2/bmap.c:329
       nilfs_collect_file_data+0x4f/0xd0 fs/nilfs2/segment.c:589
       nilfs_segctor_apply_buffers+0x161/0x330 fs/nilfs2/segment.c:1010
       nilfs_segctor_scan_file+0x68e/0x8e0 fs/nilfs2/segment.c:1059
       nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1267 [inline]
       nilfs_segctor_collect fs/nilfs2/segment.c:1547 [inline]
       nilfs_segctor_do_construct+0x1eac/0x6970 fs/nilfs2/segment.c:2122
       nilfs_segctor_construct+0x17b/0x690 fs/nilfs2/segment.c:2478
       nilfs_segctor_thread_construct fs/nilfs2/segment.c:2585 [inline]
       nilfs_segctor_thread+0x6cd/0xe00 fs/nilfs2/segment.c:2700
       kthread+0x70e/0x8a0 kernel/kthread.c:464
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

other info that might help us debug this:

Chain exists of:
  sb_internal#2 --> &nilfs->ns_segctor_sem --> &nilfs_bmap_mdt_lock_key

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&nilfs_bmap_mdt_lock_key);
                               lock(&nilfs->ns_segctor_sem);
                               lock(&nilfs_bmap_mdt_lock_key);
  rlock(sb_internal#2);

 *** DEADLOCK ***

1 lock held by segctord/5927:
 #0: ffff8880422660a0 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}, at: nilfs_bmap_propagate+0x2f/0x130 fs/nilfs2/bmap.c:328

stack backtrace:
CPU: 0 UID: 0 PID: 5927 Comm: segctord Not tainted 6.15.0-rc5-syzkaller-00136-g9c69f8884904-dirty #0 PREEMPT(full) 
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_lvl+0x189/0x250 lib/dump_stack.c:120
 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2079
 check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2211
 check_prev_add kernel/locking/lockdep.c:3166 [inline]
 check_prevs_add kernel/locking/lockdep.c:3285 [inline]
 validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
 __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
 percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
 __sb_start_write include/linux/fs.h:1783 [inline]
 sb_start_intwrite include/linux/fs.h:1966 [inline]
 nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
 nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
 nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
 nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
 nilfs_palloc_get_entry_block+0x8c/0xa0 fs/nilfs2/alloc.c:355
 nilfs_dat_prepare_entry fs/nilfs2/dat.c:45 [inline]
 nilfs_dat_prepare_alloc fs/nilfs2/dat.c:82 [inline]
 nilfs_dat_prepare_update+0xb1/0x300 fs/nilfs2/dat.c:250
 nilfs_direct_propagate+0x1ac/0x370 fs/nilfs2/direct.c:279
 nilfs_bmap_propagate+0x77/0x130 fs/nilfs2/bmap.c:329
 nilfs_collect_file_data+0x4f/0xd0 fs/nilfs2/segment.c:589
 nilfs_segctor_apply_buffers+0x161/0x330 fs/nilfs2/segment.c:1010
 nilfs_segctor_scan_file+0x68e/0x8e0 fs/nilfs2/segment.c:1059
 nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1267 [inline]
 nilfs_segctor_collect fs/nilfs2/segment.c:1547 [inline]
 nilfs_segctor_do_construct+0x1eac/0x6970 fs/nilfs2/segment.c:2122
 nilfs_segctor_construct+0x17b/0x690 fs/nilfs2/segment.c:2478
 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2585 [inline]
 nilfs_segctor_thread+0x6cd/0xe00 fs/nilfs2/segment.c:2700
 kthread+0x70e/0x8a0 kernel/kthread.c:464
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>


Tested on:

commit:         9c69f888 Merge tag 'bcachefs-2025-05-08' of git://evil..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11a694d4580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=91c351a0f6229e67
dashboard link: https://syzkaller.appspot.com/bug?extid=81394db39b0e2ed2db06
compiler:       Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
patch:          https://syzkaller.appspot.com/x/patch.diff?x=10c74768580000


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct
  2025-05-09 13:46   ` syzbot
@ 2025-05-10 13:31     ` Ryusuke Konishi
  2025-05-10 13:49       ` Ryusuke Konishi
  0 siblings, 1 reply; 6+ messages in thread
From: Ryusuke Konishi @ 2025-05-10 13:31 UTC (permalink / raw)
  To: syzbot; +Cc: syzkaller-bugs, linux-kernel, eadavis

On Sat, May 10, 2025 at 9:46 PM syzbot
<syzbot+81394db39b0e2ed2db06@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> possible deadlock in nilfs_mdt_get_block
>
> ======================================================
> WARNING: possible circular locking dependency detected
> 6.15.0-rc5-syzkaller-00136-g9c69f8884904-dirty #0 Not tainted
> ------------------------------------------------------
> segctord/5927 is trying to acquire lock:
> ffff88803ffcc610 (sb_internal#2){.+.+}-{0:0}, at: nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
> ffff88803ffcc610 (sb_internal#2){.+.+}-{0:0}, at: nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
>
> but task is already holding lock:
> ffff8880422660a0 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}, at: nilfs_bmap_propagate+0x2f/0x130 fs/nilfs2/bmap.c:328
>
> which lock already depends on the new lock.
>
>
> the existing dependency chain (in reverse order) is:
>
> -> #2 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
>        nilfs_bmap_lookup_at_level+0x92/0x3d0 fs/nilfs2/bmap.c:65
>        nilfs_bmap_lookup fs/nilfs2/bmap.h:182 [inline]
>        nilfs_mdt_submit_block+0x3a3/0x830 fs/nilfs2/mdt.c:144
>        nilfs_mdt_read_block+0x46/0x320 fs/nilfs2/mdt.c:178
>        nilfs_mdt_get_block+0x11f/0xab0 fs/nilfs2/mdt.c:254
>        nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
>        nilfs_palloc_get_desc_block fs/nilfs2/alloc.c:296 [inline]
>        nilfs_palloc_prepare_alloc_entry+0x3a3/0xf40 fs/nilfs2/alloc.c:607
>        nilfs_ifile_create_inode+0x111/0x2e0 fs/nilfs2/ifile.c:61
>        nilfs_new_inode+0x1ed/0x750 fs/nilfs2/inode.c:321
>        nilfs_create+0x100/0x2f0 fs/nilfs2/namei.c:98
>        lookup_open fs/namei.c:3701 [inline]
>        open_last_lookups fs/namei.c:3800 [inline]
>        path_openat+0x14f1/0x3830 fs/namei.c:4036
>        do_filp_open+0x1fa/0x410 fs/namei.c:4066
>        do_sys_openat2+0x121/0x1c0 fs/open.c:1429
>        do_sys_open fs/open.c:1444 [inline]
>        __do_sys_openat fs/open.c:1460 [inline]
>        __se_sys_openat fs/open.c:1455 [inline]
>        __x64_sys_openat+0x138/0x170 fs/open.c:1455
>        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
>        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
>        entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> -> #1 (&nilfs->ns_segctor_sem){++++}-{4:4}:
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
>        nilfs_transaction_begin+0x365/0x710 fs/nilfs2/segment.c:221
>        nilfs_create+0xc9/0x2f0 fs/nilfs2/namei.c:95
>        lookup_open fs/namei.c:3701 [inline]
>        open_last_lookups fs/namei.c:3800 [inline]
>        path_openat+0x14f1/0x3830 fs/namei.c:4036
>        do_filp_open+0x1fa/0x410 fs/namei.c:4066
>        do_sys_openat2+0x121/0x1c0 fs/open.c:1429
>        do_sys_open fs/open.c:1444 [inline]
>        __do_sys_openat fs/open.c:1460 [inline]
>        __se_sys_openat fs/open.c:1455 [inline]
>        __x64_sys_openat+0x138/0x170 fs/open.c:1455
>        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
>        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
>        entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> -> #0 (sb_internal#2){.+.+}-{0:0}:
>        check_prev_add kernel/locking/lockdep.c:3166 [inline]
>        check_prevs_add kernel/locking/lockdep.c:3285 [inline]
>        validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
>        __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
>        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>        percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
>        __sb_start_write include/linux/fs.h:1783 [inline]
>        sb_start_intwrite include/linux/fs.h:1966 [inline]
>        nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
>        nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
>        nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
>        nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
>        nilfs_palloc_get_entry_block+0x8c/0xa0 fs/nilfs2/alloc.c:355
>        nilfs_dat_prepare_entry fs/nilfs2/dat.c:45 [inline]
>        nilfs_dat_prepare_alloc fs/nilfs2/dat.c:82 [inline]
>        nilfs_dat_prepare_update+0xb1/0x300 fs/nilfs2/dat.c:250
>        nilfs_direct_propagate+0x1ac/0x370 fs/nilfs2/direct.c:279
>        nilfs_bmap_propagate+0x77/0x130 fs/nilfs2/bmap.c:329
>        nilfs_collect_file_data+0x4f/0xd0 fs/nilfs2/segment.c:589
>        nilfs_segctor_apply_buffers+0x161/0x330 fs/nilfs2/segment.c:1010
>        nilfs_segctor_scan_file+0x68e/0x8e0 fs/nilfs2/segment.c:1059
>        nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1267 [inline]
>        nilfs_segctor_collect fs/nilfs2/segment.c:1547 [inline]
>        nilfs_segctor_do_construct+0x1eac/0x6970 fs/nilfs2/segment.c:2122
>        nilfs_segctor_construct+0x17b/0x690 fs/nilfs2/segment.c:2478
>        nilfs_segctor_thread_construct fs/nilfs2/segment.c:2585 [inline]
>        nilfs_segctor_thread+0x6cd/0xe00 fs/nilfs2/segment.c:2700
>        kthread+0x70e/0x8a0 kernel/kthread.c:464
>        ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
>        ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
>
> other info that might help us debug this:
>
> Chain exists of:
>   sb_internal#2 --> &nilfs->ns_segctor_sem --> &nilfs_bmap_mdt_lock_key
>
>  Possible unsafe locking scenario:
>
>        CPU0                    CPU1
>        ----                    ----
>   lock(&nilfs_bmap_mdt_lock_key);
>                                lock(&nilfs->ns_segctor_sem);
>                                lock(&nilfs_bmap_mdt_lock_key);
>   rlock(sb_internal#2);
>
>  *** DEADLOCK ***
>
> 1 lock held by segctord/5927:
>  #0: ffff8880422660a0 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}, at: nilfs_bmap_propagate+0x2f/0x130 fs/nilfs2/bmap.c:328
>
> stack backtrace:
> CPU: 0 UID: 0 PID: 5927 Comm: segctord Not tainted 6.15.0-rc5-syzkaller-00136-g9c69f8884904-dirty #0 PREEMPT(full)
> 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_lvl+0x189/0x250 lib/dump_stack.c:120
>  print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2079
>  check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2211
>  check_prev_add kernel/locking/lockdep.c:3166 [inline]
>  check_prevs_add kernel/locking/lockdep.c:3285 [inline]
>  validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
>  __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
>  lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
>  percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
>  __sb_start_write include/linux/fs.h:1783 [inline]
>  sb_start_intwrite include/linux/fs.h:1966 [inline]
>  nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
>  nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
>  nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
>  nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
>  nilfs_palloc_get_entry_block+0x8c/0xa0 fs/nilfs2/alloc.c:355
>  nilfs_dat_prepare_entry fs/nilfs2/dat.c:45 [inline]
>  nilfs_dat_prepare_alloc fs/nilfs2/dat.c:82 [inline]
>  nilfs_dat_prepare_update+0xb1/0x300 fs/nilfs2/dat.c:250
>  nilfs_direct_propagate+0x1ac/0x370 fs/nilfs2/direct.c:279
>  nilfs_bmap_propagate+0x77/0x130 fs/nilfs2/bmap.c:329
>  nilfs_collect_file_data+0x4f/0xd0 fs/nilfs2/segment.c:589
>  nilfs_segctor_apply_buffers+0x161/0x330 fs/nilfs2/segment.c:1010
>  nilfs_segctor_scan_file+0x68e/0x8e0 fs/nilfs2/segment.c:1059
>  nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1267 [inline]
>  nilfs_segctor_collect fs/nilfs2/segment.c:1547 [inline]
>  nilfs_segctor_do_construct+0x1eac/0x6970 fs/nilfs2/segment.c:2122
>  nilfs_segctor_construct+0x17b/0x690 fs/nilfs2/segment.c:2478
>  nilfs_segctor_thread_construct fs/nilfs2/segment.c:2585 [inline]
>  nilfs_segctor_thread+0x6cd/0xe00 fs/nilfs2/segment.c:2700
>  kthread+0x70e/0x8a0 kernel/kthread.c:464
>  ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
>  ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
>  </TASK>
>
>
> Tested on:
>
> commit:         9c69f888 Merge tag 'bcachefs-2025-05-08' of git://evil..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=11a694d4580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=91c351a0f6229e67
> dashboard link: https://syzkaller.appspot.com/bug?extid=81394db39b0e2ed2db06
> compiler:       Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
> patch:          https://syzkaller.appspot.com/x/patch.diff?x=10c74768580000
>
>

This reports a different circular lock dependency than all other
reports in this issue, so it appears to be a separate issue. I'd like
to dig deeper.

Ryusuke Konishi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct
  2025-05-10 13:31     ` Ryusuke Konishi
@ 2025-05-10 13:49       ` Ryusuke Konishi
  0 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2025-05-10 13:49 UTC (permalink / raw)
  To: syzbot; +Cc: eadavis, syzkaller-bugs, linux-kernel

On Sat, May 10, 2025 at 10:31 PM Ryusuke Konishi wrote:
>
> On Sat, May 10, 2025 at 9:46 PM syzbot
> <syzbot+81394db39b0e2ed2db06@syzkaller.appspotmail.com> wrote:
> >
> > Hello,
> >
> > syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> > possible deadlock in nilfs_mdt_get_block
> >
> > ======================================================
> > WARNING: possible circular locking dependency detected
> > 6.15.0-rc5-syzkaller-00136-g9c69f8884904-dirty #0 Not tainted
> > ------------------------------------------------------
> > segctord/5927 is trying to acquire lock:
> > ffff88803ffcc610 (sb_internal#2){.+.+}-{0:0}, at: nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
> > ffff88803ffcc610 (sb_internal#2){.+.+}-{0:0}, at: nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
> >
> > but task is already holding lock:
> > ffff8880422660a0 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}, at: nilfs_bmap_propagate+0x2f/0x130 fs/nilfs2/bmap.c:328
> >
> > which lock already depends on the new lock.
> >
> >
> > the existing dependency chain (in reverse order) is:
> >
> > -> #2 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}:
> >        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
> >        down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
> >        nilfs_bmap_lookup_at_level+0x92/0x3d0 fs/nilfs2/bmap.c:65
> >        nilfs_bmap_lookup fs/nilfs2/bmap.h:182 [inline]
> >        nilfs_mdt_submit_block+0x3a3/0x830 fs/nilfs2/mdt.c:144
> >        nilfs_mdt_read_block+0x46/0x320 fs/nilfs2/mdt.c:178
> >        nilfs_mdt_get_block+0x11f/0xab0 fs/nilfs2/mdt.c:254
> >        nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
> >        nilfs_palloc_get_desc_block fs/nilfs2/alloc.c:296 [inline]
> >        nilfs_palloc_prepare_alloc_entry+0x3a3/0xf40 fs/nilfs2/alloc.c:607
> >        nilfs_ifile_create_inode+0x111/0x2e0 fs/nilfs2/ifile.c:61
> >        nilfs_new_inode+0x1ed/0x750 fs/nilfs2/inode.c:321
> >        nilfs_create+0x100/0x2f0 fs/nilfs2/namei.c:98
> >        lookup_open fs/namei.c:3701 [inline]
> >        open_last_lookups fs/namei.c:3800 [inline]
> >        path_openat+0x14f1/0x3830 fs/namei.c:4036
> >        do_filp_open+0x1fa/0x410 fs/namei.c:4066
> >        do_sys_openat2+0x121/0x1c0 fs/open.c:1429
> >        do_sys_open fs/open.c:1444 [inline]
> >        __do_sys_openat fs/open.c:1460 [inline]
> >        __se_sys_openat fs/open.c:1455 [inline]
> >        __x64_sys_openat+0x138/0x170 fs/open.c:1455
> >        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> >        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
> >        entry_SYSCALL_64_after_hwframe+0x77/0x7f
> >
> > -> #1 (&nilfs->ns_segctor_sem){++++}-{4:4}:
> >        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
> >        down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
> >        nilfs_transaction_begin+0x365/0x710 fs/nilfs2/segment.c:221
> >        nilfs_create+0xc9/0x2f0 fs/nilfs2/namei.c:95
> >        lookup_open fs/namei.c:3701 [inline]
> >        open_last_lookups fs/namei.c:3800 [inline]
> >        path_openat+0x14f1/0x3830 fs/namei.c:4036
> >        do_filp_open+0x1fa/0x410 fs/namei.c:4066
> >        do_sys_openat2+0x121/0x1c0 fs/open.c:1429
> >        do_sys_open fs/open.c:1444 [inline]
> >        __do_sys_openat fs/open.c:1460 [inline]
> >        __se_sys_openat fs/open.c:1455 [inline]
> >        __x64_sys_openat+0x138/0x170 fs/open.c:1455
> >        do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> >        do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
> >        entry_SYSCALL_64_after_hwframe+0x77/0x7f
> >
> > -> #0 (sb_internal#2){.+.+}-{0:0}:
> >        check_prev_add kernel/locking/lockdep.c:3166 [inline]
> >        check_prevs_add kernel/locking/lockdep.c:3285 [inline]
> >        validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
> >        __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
> >        lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
> >        percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
> >        __sb_start_write include/linux/fs.h:1783 [inline]
> >        sb_start_intwrite include/linux/fs.h:1966 [inline]
> >        nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
> >        nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
> >        nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
> >        nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
> >        nilfs_palloc_get_entry_block+0x8c/0xa0 fs/nilfs2/alloc.c:355
> >        nilfs_dat_prepare_entry fs/nilfs2/dat.c:45 [inline]
> >        nilfs_dat_prepare_alloc fs/nilfs2/dat.c:82 [inline]
> >        nilfs_dat_prepare_update+0xb1/0x300 fs/nilfs2/dat.c:250
> >        nilfs_direct_propagate+0x1ac/0x370 fs/nilfs2/direct.c:279
> >        nilfs_bmap_propagate+0x77/0x130 fs/nilfs2/bmap.c:329
> >        nilfs_collect_file_data+0x4f/0xd0 fs/nilfs2/segment.c:589
> >        nilfs_segctor_apply_buffers+0x161/0x330 fs/nilfs2/segment.c:1010
> >        nilfs_segctor_scan_file+0x68e/0x8e0 fs/nilfs2/segment.c:1059
> >        nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1267 [inline]
> >        nilfs_segctor_collect fs/nilfs2/segment.c:1547 [inline]
> >        nilfs_segctor_do_construct+0x1eac/0x6970 fs/nilfs2/segment.c:2122
> >        nilfs_segctor_construct+0x17b/0x690 fs/nilfs2/segment.c:2478
> >        nilfs_segctor_thread_construct fs/nilfs2/segment.c:2585 [inline]
> >        nilfs_segctor_thread+0x6cd/0xe00 fs/nilfs2/segment.c:2700
> >        kthread+0x70e/0x8a0 kernel/kthread.c:464
> >        ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
> >        ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
> >
> > other info that might help us debug this:
> >
> > Chain exists of:
> >   sb_internal#2 --> &nilfs->ns_segctor_sem --> &nilfs_bmap_mdt_lock_key
> >
> >  Possible unsafe locking scenario:
> >
> >        CPU0                    CPU1
> >        ----                    ----
> >   lock(&nilfs_bmap_mdt_lock_key);
> >                                lock(&nilfs->ns_segctor_sem);
> >                                lock(&nilfs_bmap_mdt_lock_key);
> >   rlock(sb_internal#2);
> >
> >  *** DEADLOCK ***
> >
> > 1 lock held by segctord/5927:
> >  #0: ffff8880422660a0 (&nilfs_bmap_mdt_lock_key){++++}-{4:4}, at: nilfs_bmap_propagate+0x2f/0x130 fs/nilfs2/bmap.c:328
> >
> > stack backtrace:
> > CPU: 0 UID: 0 PID: 5927 Comm: segctord Not tainted 6.15.0-rc5-syzkaller-00136-g9c69f8884904-dirty #0 PREEMPT(full)
> > 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_lvl+0x189/0x250 lib/dump_stack.c:120
> >  print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2079
> >  check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2211
> >  check_prev_add kernel/locking/lockdep.c:3166 [inline]
> >  check_prevs_add kernel/locking/lockdep.c:3285 [inline]
> >  validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
> >  __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
> >  lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
> >  percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
> >  __sb_start_write include/linux/fs.h:1783 [inline]
> >  sb_start_intwrite include/linux/fs.h:1966 [inline]
> >  nilfs_transaction_begin+0x268/0x710 fs/nilfs2/segment.c:218
> >  nilfs_mdt_create_block fs/nilfs2/mdt.c:80 [inline]
> >  nilfs_mdt_get_block+0x193/0xab0 fs/nilfs2/mdt.c:258
> >  nilfs_palloc_get_block+0x18d/0x2b0 fs/nilfs2/alloc.c:239
> >  nilfs_palloc_get_entry_block+0x8c/0xa0 fs/nilfs2/alloc.c:355
> >  nilfs_dat_prepare_entry fs/nilfs2/dat.c:45 [inline]
> >  nilfs_dat_prepare_alloc fs/nilfs2/dat.c:82 [inline]
> >  nilfs_dat_prepare_update+0xb1/0x300 fs/nilfs2/dat.c:250
> >  nilfs_direct_propagate+0x1ac/0x370 fs/nilfs2/direct.c:279
> >  nilfs_bmap_propagate+0x77/0x130 fs/nilfs2/bmap.c:329
> >  nilfs_collect_file_data+0x4f/0xd0 fs/nilfs2/segment.c:589
> >  nilfs_segctor_apply_buffers+0x161/0x330 fs/nilfs2/segment.c:1010
> >  nilfs_segctor_scan_file+0x68e/0x8e0 fs/nilfs2/segment.c:1059
> >  nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1267 [inline]
> >  nilfs_segctor_collect fs/nilfs2/segment.c:1547 [inline]
> >  nilfs_segctor_do_construct+0x1eac/0x6970 fs/nilfs2/segment.c:2122
> >  nilfs_segctor_construct+0x17b/0x690 fs/nilfs2/segment.c:2478
> >  nilfs_segctor_thread_construct fs/nilfs2/segment.c:2585 [inline]
> >  nilfs_segctor_thread+0x6cd/0xe00 fs/nilfs2/segment.c:2700
> >  kthread+0x70e/0x8a0 kernel/kthread.c:464
> >  ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:153
> >  ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
> >  </TASK>
> >
> >
> > Tested on:
> >
> > commit:         9c69f888 Merge tag 'bcachefs-2025-05-08' of git://evil..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=11a694d4580000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=91c351a0f6229e67
> > dashboard link: https://syzkaller.appspot.com/bug?extid=81394db39b0e2ed2db06
> > compiler:       Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
> > patch:          https://syzkaller.appspot.com/x/patch.diff?x=10c74768580000
> >
> >
>
> This reports a different circular lock dependency than all other
> reports in this issue, so it appears to be a separate issue. I'd like
> to dig deeper.
>
> Ryusuke Konishi

Oops, I misunderstood.
This was the result of testing the following patch:

https://syzkaller.appspot.com/x/patch.diff?x=10c74768580000

Just sharing the info, the original issue (extid=81394db39b0e2ed2db06)
should be resolved with the following patch sent upstream:

https://lore.kernel.org/all/20250503053327.12294-1-konishi.ryusuke@gmail.com/

Ryusuke Konishi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-10 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 16:22 [syzbot] [nilfs?] possible deadlock in nilfs_segctor_construct syzbot
2025-05-08 16:37 ` Ryusuke Konishi
2025-05-09 13:29 ` Edward Adam Davis
2025-05-09 13:46   ` syzbot
2025-05-10 13:31     ` Ryusuke Konishi
2025-05-10 13:49       ` Ryusuke Konishi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.