[syzbot] [bcachefs?] INFO: task hung in bch2_seek_pagecache_hole (3)

9 views
Skip to first unread message

syzbot

unread,
Sep 17, 2025, 6:54:30 PMSep 17
to kent.ov...@linux.dev, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 5aca7966d2a7 Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=137baf62580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f5b21423ca3f0a96
dashboard link: https://syzkaller.appspot.com/bug?extid=cb91f22d8a581fc19edf
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16342e42580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15c4c534580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/4946b6719e9f/disk-5aca7966.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f982750cccde/vmlinux-5aca7966.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e070a17d9c63/bzImage-5aca7966.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/2615c2777a3c/mount_0.gz

The issue was bisected to:

commit c02e5b57283ad6fd8dec8d834bd340bf2627fcee
Author: Kent Overstreet <kent.ov...@linux.dev>
Date: Wed Apr 2 19:12:49 2025 +0000

bcachefs: Single device mode

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15a34c7c580000
final oops: https://syzkaller.appspot.com/x/report.txt?x=17a34c7c580000
console output: https://syzkaller.appspot.com/x/log.txt?x=13a34c7c580000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+cb91f2...@syzkaller.appspotmail.com
Fixes: c02e5b57283a ("bcachefs: Single device mode")

INFO: task syz.3.20:6170 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.3.20 state:D stack:21416 pid:6170 tgid:6147 ppid:5988 task_flags:0x400040 flags:0x00004006
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5357 [inline]
__schedule+0x16f3/0x4c20 kernel/sched/core.c:6961
__schedule_loop kernel/sched/core.c:7043 [inline]
schedule+0x165/0x360 kernel/sched/core.c:7058
io_schedule+0x81/0xe0 kernel/sched/core.c:7903
folio_wait_bit_common+0x6b5/0xb90 mm/filemap.c:1317
__folio_lock mm/filemap.c:1675 [inline]
folio_lock include/linux/pagemap.h:1133 [inline]
__filemap_get_folio+0x167/0xa40 mm/filemap.c:1929
folio_hole_offset fs/bcachefs/fs-io-pagecache.c:756 [inline]
bch2_seek_pagecache_hole+0xbb/0x7c0 fs/bcachefs/fs-io-pagecache.c:793
bch2_clamp_data_hole+0x8f/0x180 fs/bcachefs/fs-io-pagecache.c:808
__bchfs_fallocate+0xe77/0x1870 fs/bcachefs/fs-io.c:697
bchfs_fallocate+0x33f/0x680 fs/bcachefs/fs-io.c:789
bch2_fallocate_dispatch+0x28d/0x410 fs/bcachefs/fs-io.c:836
vfs_fallocate+0x672/0x7f0 fs/open.c:342
ksys_fallocate fs/open.c:366 [inline]
__do_sys_fallocate fs/open.c:371 [inline]
__se_sys_fallocate fs/open.c:369 [inline]
__x64_sys_fallocate+0xc0/0x110 fs/open.c:369
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7feb0096eba9
RSP: 002b:00007feafffb5038 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007feb00bb6090 RCX: 00007feb0096eba9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007feb009f1e19 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000001001ec R11: 0000000000000246 R12: 0000000000000000
R13: 00007feb00bb6128 R14: 00007feb00bb6090 R15: 00007ffc531dd1d8
</TASK>
INFO: task syz.3.20:6171 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.3.20 state:D stack:26248 pid:6171 tgid:6147 ppid:5988 task_flags:0x440040 flags:0x00004004
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5357 [inline]
__schedule+0x16f3/0x4c20 kernel/sched/core.c:6961
__schedule_loop kernel/sched/core.c:7043 [inline]
schedule+0x165/0x360 kernel/sched/core.c:7058
__bch2_two_state_lock+0x1ea/0x370 fs/bcachefs/two_state_shared_lock.c:7
bch2_two_state_lock fs/bcachefs/two_state_shared_lock.h:55 [inline]
bch2_readahead+0x94f/0x1100 fs/bcachefs/fs-io-buffered.c:296
read_pages+0x177/0x580 mm/readahead.c:160
page_cache_ra_unbounded+0x63b/0x740 mm/readahead.c:297
filemap_get_pages+0x443/0x1df0 mm/filemap.c:2603
filemap_splice_read+0x587/0xc60 mm/filemap.c:2991
do_splice_read fs/splice.c:982 [inline]
splice_direct_to_actor+0x4b1/0xcd0 fs/splice.c:1086
do_splice_direct_actor fs/splice.c:1204 [inline]
do_splice_direct+0x187/0x270 fs/splice.c:1230
vfs_copy_file_range+0xad7/0x1330 fs/read_write.c:1627
__do_sys_copy_file_range fs/read_write.c:1677 [inline]
__se_sys_copy_file_range+0x2fb/0x470 fs/read_write.c:1644
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7feb0096eba9
RSP: 002b:00007feafff94038 EFLAGS: 00000246 ORIG_RAX: 0000000000000146
RAX: ffffffffffffffda RBX: 00007feb00bb6180 RCX: 00007feb0096eba9
RDX: 0000000000000004 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007feb009f1e19 R08: 0000000000000101 R09: 0000000000000000
R10: 00002000000000c0 R11: 0000000000000246 R12: 0000000000000000
R13: 00007feb00bb6218 R14: 00007feb00bb6180 R15: 00007ffc531dd1d8
</TASK>

Showing all locks held in the system:
2 locks held by kworker/u8:1/13:
#0: ffff888019881138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
#0: ffff888019881138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x17b0 kernel/workqueue.c:3319
#1: ffffc90000127bc0 ((reaper_work).work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
#1: ffffc90000127bc0 ((reaper_work).work){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x17b0 kernel/workqueue.c:3319
2 locks held by kworker/u8:2/37:
#0: ffff888019881138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
#0: ffff888019881138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x17b0 kernel/workqueue.c:3319
#1: ffffc90000ac7bc0 (connector_reaper_work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
#1: ffffc90000ac7bc0 (connector_reaper_work){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x17b0 kernel/workqueue.c:3319
1 lock held by khungtaskd/39:
#0: ffffffff8d9a8d80 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline]
#0: ffffffff8d9a8d80 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:841 [inline]
#0: ffffffff8d9a8d80 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x2e/0x180 kernel/locking/lockdep.c:6775
2 locks held by kworker/u8:3/57:
#0: ffff888019881138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
#0: ffff888019881138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x17b0 kernel/workqueue.c:3319
#1: ffffc9000123fbc0 ((work_completion)(&(&kfence_timer)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
#1: ffffc9000123fbc0 ((work_completion)(&(&kfence_timer)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x17b0 kernel/workqueue.c:3319
2 locks held by kworker/u8:15/3581:
2 locks held by getty/5601:
#0: ffff88823bf700a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:243
#1: ffffc90003e762e0 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x444/0x1410 drivers/tty/n_tty.c:2222
1 lock held by udevd/6029:
2 locks held by udevd/6043:
3 locks held by syz.3.20/6170:
#0: ffff88803941a488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88803941a488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d6009b8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d6009b8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff88805a404678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88805a404678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88805a404678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.3.20/6171:
#0: ffff88805d600b88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d600b88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.0.17/6189:
#0: ffff888021f46488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888021f46488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d7f89b8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d7f89b8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff888055304678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888055304678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888055304678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.0.17/6191:
#0: ffff88805d7f8b88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d7f8b88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.1.18/6204:
#0: ffff888058a7a488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888058a7a488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d601a38 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d601a38 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff888059404678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888059404678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888059404678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.1.18/6209:
#0: ffff88805d601c08 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d601c08 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.4.23/6255:
#0: ffff88803db8c488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88803db8c488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d604bb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d604bb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff888065204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888065204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888065204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.4.23/6256:
#0: ffff88805d604d88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d604d88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
1 lock held by syz.2.40/6491:
#0: ffff88805d7f93c8 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d7f93c8 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.2.40/6513:
#0: ffff88805d13e488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88805d13e488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d7f91f8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d7f91f8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff88806de04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88806de04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88806de04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
3 locks held by syz.5.28/6539:
#0: ffff8881413d8488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff8881413d8488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d7fd3f8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d7fd3f8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff88806dd04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88806dd04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88806dd04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.5.28/6540:
#0: ffff88805d7fd5c8 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d7fd5c8 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
1 lock held by syz.6.30/6542:
#0: ffff88805d602c88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d602c88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.6.30/6555:
#0: ffff88804856e488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88804856e488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d602ab8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d602ab8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff88806d904678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88806d904678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88806d904678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
3 locks held by syz.8.35/6579:
#0: ffff88806dc8e488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88806dc8e488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88805d602278 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88805d602278 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff88806cc04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88806cc04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88806cc04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.8.35/6580:
#0: ffff88805d602448 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88805d602448 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.9.46/6851:
#0: ffff888054616488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888054616488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888075d6cbb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888075d6cbb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff88807d204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88807d204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88807d204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.9.46/6852:
#0: ffff888075d6cd88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888075d6cd88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.7.60/6896:
#0: ffff888027a44488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888027a44488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888075d6d3f8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888075d6d3f8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:827
#2: ffff888083204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888083204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888083204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.7.60/6897:
#0: ffff888075d6d5c8 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888075d6d5c8 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
2 locks held by syz.0.167/7213:
1 lock held by syz.3.168/7216:
3 locks held by syz.2.169/7219:
4 locks held by syz.1.170/7222:
2 locks held by syz.4.171/7225:

=============================================

NMI backtrace for cpu 1
CPU: 1 UID: 0 PID: 39 Comm: khungtaskd Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025
Call Trace:
<TASK>
dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
nmi_cpu_backtrace+0x39e/0x3d0 lib/nmi_backtrace.c:113
nmi_trigger_cpumask_backtrace+0x17a/0x300 lib/nmi_backtrace.c:62
trigger_all_cpu_backtrace include/linux/nmi.h:160 [inline]
check_hung_uninterruptible_tasks kernel/hung_task.c:328 [inline]
watchdog+0xf93/0xfe0 kernel/hung_task.c:491
kthread+0x70e/0x8a0 kernel/kthread.c:463
ret_from_fork+0x439/0x7d0 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Sending NMI from CPU 1 to CPUs 0:
NMI backtrace for cpu 0
CPU: 0 UID: 0 PID: 17 Comm: pr/legacy Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025
RIP: 0010:io_serial_in+0x77/0xc0 drivers/tty/serial/8250/8250_port.c:400
Code: e8 ae 4e 7f fc 44 89 f9 d3 e3 49 83 ee 80 4c 89 f0 48 c1 e8 03 42 80 3c 20 00 74 08 4c 89 f7 e8 4f 89 de fc 41 03 1e 89 da ec <0f> b6 c0 5b 41 5c 41 5e 41 5f e9 0a 81 bb 05 cc 44 89 f9 80 e1 07
RSP: 0018:ffffc90000167890 EFLAGS: 00000202
RAX: 1ffffffff3275c00 RBX: 00000000000003fd RCX: 0000000000000000
RDX: 00000000000003fd RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffffff993ae870 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: ffffffff853f1f10 R12: dffffc0000000000
R13: 0000000000000000 R14: ffffffff993ae5e0 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff8881268bc000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f20e01f8000 CR3: 000000003ae94000 CR4: 00000000003526f0
Call Trace:
<TASK>
serial_in drivers/tty/serial/8250/8250.h:137 [inline]
serial_lsr_in drivers/tty/serial/8250/8250.h:159 [inline]
wait_for_lsr+0x1a7/0x2f0 drivers/tty/serial/8250/8250_port.c:1984
fifo_wait_for_lsr drivers/tty/serial/8250/8250_port.c:3288 [inline]
serial8250_console_fifo_write drivers/tty/serial/8250/8250_port.c:3311 [inline]
serial8250_console_write+0x11bd/0x1b40 drivers/tty/serial/8250/8250_port.c:3396
console_emit_next_record kernel/printk/printk.c:3118 [inline]
console_flush_all+0x695/0xcd0 kernel/printk/printk.c:3226
__console_flush_and_unlock+0xa4/0x240 kernel/printk/printk.c:3285
legacy_kthread_func+0x13b/0x1a0 kernel/printk/printk.c:3638
kthread+0x70e/0x8a0 kernel/kthread.c:463
ret_from_fork+0x439/0x7d0 arch/x86/kernel/process.c:148
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

syzbot

unread,
Sep 27, 2025, 2:53:59 AMSep 27
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: [PATCH] bcachefs: Fix deadlock between fallocate and readahead
Author: karti...@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

There is an ABBA deadlock between fallocate and readahead operations:

Thread 1 (fallocate):
bch2_fallocate_dispatch
inode_lock(&inode->v)
bch2_pagecache_block_get(inode) // Acquires two_state_lock
__bchfs_fallocate
bch2_clamp_data_hole
bch2_seek_pagecache_hole
__filemap_get_folio
folio_lock() // BLOCKS - Thread 2 holds it

Thread 2 (readahead via copy_file_range):
bch2_readahead
folio_lock() // Holds page lock
__bch2_two_state_lock(&pagecache_lock) // BLOCKS - Thread 1 holds it

The issue is that drop_locks_do() only releases btree transaction locks,
but Thread 2 is blocked waiting for the two_state_lock (pagecache_block)
held by bch2_pagecache_block_get().

Fix by explicitly releasing and re-acquiring the pagecache_block lock
around the blocking bch2_clamp_data_hole() call, following the same
pattern used in bch2_page_fault(). Force a transaction restart after
lock release to ensure consistency.

Reported-by: syzbot+cb91f2...@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=cb91f22d8a581fc19edf
Signed-off-by: Deepanshu Kartikey <Karti...@gmail.com>
---
fs/bcachefs/fs-io.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index a233f45875e9..04f76d141b17 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -694,13 +694,19 @@ static noinline int __bchfs_fallocate(struct bch_inode_info *inode, int mode,
&hole_start,
&hole_end,
opts.data_replicas, true)) {
+ /* Release pagecache_block to prevent deadlock with readahead */
+ bch2_pagecache_block_put(inode);
ret = drop_locks_do(trans,
(bch2_clamp_data_hole(&inode->v,
&hole_start,
&hole_end,
opts.data_replicas, false), 0));
+ bch2_pagecache_block_get(inode);
if (ret)
goto bkey_err;
+ /* Force transaction restart to revalidate state */
+ ret = -BCH_ERR_transaction_restart;
+ goto bkey_err;
}
bch2_btree_iter_set_pos(trans, &iter, POS(iter.pos.inode, hole_start));

--
2.43.0

syzbot

unread,
Sep 27, 2025, 2:53:59 AMSep 27
to linux-...@vger.kernel.org, syzkall...@googlegroups.com

syzbot

unread,
Sep 27, 2025, 3:12:04 AMSep 27
to =sy...@syzkaller.appspotmail.com, karti...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
INFO: task hung in bch2_readahead

INFO: task syz.1.18:6662 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.1.18 state:D stack:17448 pid:6662 tgid:6661 ppid:6353 task_flags:0x440140 flags:0x00004004
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5357 [inline]
__schedule+0x16f3/0x4c20 kernel/sched/core.c:6961
__schedule_loop kernel/sched/core.c:7043 [inline]
schedule+0x165/0x360 kernel/sched/core.c:7058
__bch2_two_state_lock+0x1ea/0x370 fs/bcachefs/two_state_shared_lock.c:7
bch2_two_state_lock fs/bcachefs/two_state_shared_lock.h:55 [inline]
bch2_readahead+0x94f/0x1100 fs/bcachefs/fs-io-buffered.c:296
read_pages+0x17a/0x580 mm/readahead.c:160
page_cache_ra_unbounded+0x63b/0x740 mm/readahead.c:297
filemap_get_pages+0x443/0x1df0 mm/filemap.c:2603
filemap_splice_read+0x587/0xc60 mm/filemap.c:2991
do_splice_read fs/splice.c:982 [inline]
splice_direct_to_actor+0x4b1/0xcd0 fs/splice.c:1086
do_splice_direct_actor fs/splice.c:1204 [inline]
do_splice_direct+0x187/0x270 fs/splice.c:1230
vfs_copy_file_range+0xad7/0x1330 fs/read_write.c:1627
__do_sys_copy_file_range fs/read_write.c:1677 [inline]
__se_sys_copy_file_range+0x2fb/0x470 fs/read_write.c:1644
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1edf09eba9
RSP: 002b:00007f1ede706038 EFLAGS: 00000246 ORIG_RAX: 0000000000000146
RAX: ffffffffffffffda RBX: 00007f1edf2e5fa0 RCX: 00007f1edf09eba9
RDX: 0000000000000004 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007f1edf121e19 R08: 0000000000000101 R09: 0000000000000000
R10: 00002000000000c0 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f1edf2e6038 R14: 00007f1edf2e5fa0 R15: 00007ffe266d1f08
</TASK>
INFO: task syz.1.18:6705 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.1.18 state:D stack:21352 pid:6705 tgid:6661 ppid:6353 task_flags:0x400040 flags:0x00004006
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5357 [inline]
__schedule+0x16f3/0x4c20 kernel/sched/core.c:6961
__schedule_loop kernel/sched/core.c:7043 [inline]
schedule+0x165/0x360 kernel/sched/core.c:7058
io_schedule+0x81/0xe0 kernel/sched/core.c:7903
folio_wait_bit_common+0x6b5/0xb90 mm/filemap.c:1317
folio_lock include/linux/pagemap.h:1133 [inline]
bch2_mark_pagecache_reserved+0x33d/0xbb0 fs/bcachefs/fs-io-pagecache.c:314
__bchfs_fallocate+0x1447/0x1a40 fs/bcachefs/fs-io.c:739
bchfs_fallocate+0x33f/0x680 fs/bcachefs/fs-io.c:795
bch2_fallocate_dispatch+0x28d/0x410 fs/bcachefs/fs-io.c:842
vfs_fallocate+0x672/0x7f0 fs/open.c:342
ksys_fallocate fs/open.c:366 [inline]
__do_sys_fallocate fs/open.c:371 [inline]
__se_sys_fallocate fs/open.c:369 [inline]
__x64_sys_fallocate+0xc0/0x110 fs/open.c:369
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1edf09eba9
RSP: 002b:00007f1ede6e5038 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007f1edf2e6090 RCX: 00007f1edf09eba9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007f1edf121e19 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000001001ec R11: 0000000000000246 R12: 0000000000000000
R13: 00007f1edf2e6128 R14: 00007f1edf2e6090 R15: 00007ffe266d1f08
</TASK>

Showing all locks held in the system:
3 locks held by kworker/u8:1/13:
#0: ffff88814d3f5138 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
#0: ffff88814d3f5138 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x17b0 kernel/workqueue.c:3319
#1: ffffc90000127bc0 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
#1: ffffc90000127bc0 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x17b0 kernel/workqueue.c:3319
#2: ffffffff8ecd38b8 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#2: ffffffff8ecd38b8 (rtnl_mutex){+.+.}-{4:4}, at: addrconf_dad_work+0x119/0x15a0 net/ipv6/addrconf.c:4194
4 locks held by pr/legacy/17:
1 lock held by khungtaskd/38:
#0: ffffffff8d9a8dc0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline]
#0: ffffffff8d9a8dc0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:841 [inline]
#0: ffffffff8d9a8dc0 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x2e/0x180 kernel/locking/lockdep.c:6775
6 locks held by kworker/u8:8/1125:
#0: ffff88806b921138 ((wq_completion)btree_update#86){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
#0: ffff88806b921138 ((wq_completion)btree_update#86){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x17b0 kernel/workqueue.c:3319
#1: ffffc90004f97bc0 ((work_completion)(&c->btree_interior_update_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
#1: ffffc90004f97bc0 ((work_completion)(&c->btree_interior_update_work)){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x17b0 kernel/workqueue.c:3319
#2: ffff888087204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888087204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888087204678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7f3/0xd80 fs/bcachefs/btree_iter.c:3505
#3: ffff888092b801b0 (bcachefs_btree){+.+.}-{0:0}, at: trans_set_locked fs/bcachefs/btree_locking.h:206 [inline]
#3: ffff888092b801b0 (bcachefs_btree){+.+.}-{0:0}, at: bch2_trans_begin+0xbd8/0x2300 fs/bcachefs/btree_iter.c:3403
#4: ffff88808726d068 (journal res){.+.+}-{0:0}, at: bch2_journal_res_get+0x6a9/0x8f0 fs/bcachefs/journal.h:406
#5: ffff888087204d38 (&c->mark_lock){++++}-{0:0}, at: bch2_accounting_mem_insert+0x438/0xad0 fs/bcachefs/disk_accounting.c:407
4 locks held by kworker/u8:10/1163:
1 lock held by udevd/5207:
#0: ffff888035b75218 (&ep->lock){++++}-{3:3}, at: write_lock_irq include/linux/rwlock_rt.h:104 [inline]
#0: ffff888035b75218 (&ep->lock){++++}-{3:3}, at: ep_poll fs/eventpoll.c:2127 [inline]
#0: ffff888035b75218 (&ep->lock){++++}-{3:3}, at: do_epoll_wait+0x84d/0xbb0 fs/eventpoll.c:2560
2 locks held by getty/5598:
#0: ffff88823bf3a0a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:243
#1: ffffc90003e762e0 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x444/0x1410 drivers/tty/n_tty.c:2222
3 locks held by udevd/6647:
1 lock held by syz.1.18/6662:
#0: ffff888048f40b88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888048f40b88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.1.18/6705:
#0: ffff88805124c488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88805124c488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888048f409b8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888048f409b8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff88805a804678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88805a804678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88805a804678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
7 locks held by udevd/6920:
3 locks held by syz.3.39/7150:
#0: ffff888029276488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888029276488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888048f46cb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888048f46cb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff888070304678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888070304678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888070304678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.3.39/7153:
#0: ffff888048f46e88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888048f46e88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
1 lock held by syz.2.43/7217:
#0: ffff888048f42c88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888048f42c88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.2.43/7266:
#0: ffff888058224488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888058224488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888048f42ab8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888048f42ab8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff88806fc04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88806fc04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88806fc04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
3 locks held by syz.0.47/7339:
#0: ffff888030344488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888030344488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888048f1c378 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888048f1c378 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff888070c04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888070c04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888070c04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7f3/0xd80 fs/bcachefs/btree_iter.c:3505
1 lock held by syz.0.47/7340:
#0: ffff888048f1c548 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888048f1c548 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
2 locks held by syz-executor/7412:
#0: ffff888038c2a0d0 (&type->s_umount_key#54){++++}-{4:4}, at: __super_lock fs/super.c:57 [inline]
#0: ffff888038c2a0d0 (&type->s_umount_key#54){++++}-{4:4}, at: __super_lock_excl fs/super.c:72 [inline]
#0: ffff888038c2a0d0 (&type->s_umount_key#54){++++}-{4:4}, at: deactivate_super+0xa9/0xe0 fs/super.c:506
#1: ffff888087200268 (&c->state_lock){+.+.}-{4:4}, at: __bch2_fs_stop+0xf8/0x900 fs/bcachefs/super.c:676
3 locks held by syz.4.63/7563:
#0: ffff88802366a488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88802366a488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888048f1ecb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888048f1ecb8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff888087504678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff888087504678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff888087504678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.4.63/7564:
#0: ffff888048f1ee88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888048f1ee88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.5.112/8299:
#0: ffff888031282488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888031282488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888049276478 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888049276478 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff8880a3c04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff8880a3c04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff8880a3c04678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7f3/0xd80 fs/bcachefs/btree_iter.c:3505
1 lock held by syz.5.112/8302:
#0: ffff888049276648 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888049276648 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.6.119/8401:
#0: ffff888079bc0488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff888079bc0488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff888048f1a278 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff888048f1a278 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff8880b2604678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff8880b2604678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff8880b2604678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7f3/0xd80 fs/bcachefs/btree_iter.c:3505
1 lock held by syz.6.119/8402:
#0: ffff888048f1a448 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff888048f1a448 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
3 locks held by syz.8.121/8421:
#0: ffff88803d79e488 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3108 [inline]
#0: ffff88803d79e488 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5f9/0x7f0 fs/open.c:341
#1: ffff88808e622ab8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:870 [inline]
#1: ffff88808e622ab8 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: bch2_fallocate_dispatch+0x111/0x410 fs/bcachefs/fs-io.c:833
#2: ffff88809e104678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
#2: ffff88809e104678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
#2: ffff88809e104678 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
1 lock held by syz.8.121/8422:
#0: ffff88808e622c88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:935 [inline]
#0: ffff88808e622c88 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xf4/0x740 mm/readahead.c:228
1 lock held by syz-executor/8442:
#0: ffffffff8ecd38b8 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#0: ffffffff8ecd38b8 (rtnl_mutex){+.+.}-{4:4}, at: inet6_rtm_newaddr+0x5b7/0xd20 net/ipv6/addrconf.c:5027
1 lock held by syz-executor/8511:
#0: ffffffff8ecd38b8 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#0: ffffffff8ecd38b8 (rtnl_mutex){+.+.}-{4:4}, at: inet6_rtm_newaddr+0x5b7/0xd20 net/ipv6/addrconf.c:5027
2 locks held by syz-executor/8557:

=============================================

NMI backtrace for cpu 0
CPU: 0 UID: 0 PID: 38 Comm: khungtaskd Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025
Call Trace:
<TASK>
dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
nmi_cpu_backtrace+0x39e/0x3d0 lib/nmi_backtrace.c:113
nmi_trigger_cpumask_backtrace+0x17a/0x300 lib/nmi_backtrace.c:62
trigger_all_cpu_backtrace include/linux/nmi.h:160 [inline]
check_hung_uninterruptible_tasks kernel/hung_task.c:328 [inline]
watchdog+0xf93/0xfe0 kernel/hung_task.c:491
kthread+0x711/0x8a0 kernel/kthread.c:463
ret_from_fork+0x436/0x7d0 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1
CPU: 1 UID: 0 PID: 17 Comm: pr/legacy Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025
RIP: 0010:io_serial_in+0x77/0xc0 drivers/tty/serial/8250/8250_port.c:400
Code: e8 0e 31 7f fc 44 89 f9 d3 e3 49 83 ee 80 4c 89 f0 48 c1 e8 03 42 80 3c 20 00 74 08 4c 89 f7 e8 9f 77 de fc 41 03 1e 89 da ec <0f> b6 c0 5b 41 5c 41 5e 41 5f c3 cc cc cc cc cc 44 89 f9 80 e1 07
RSP: 0018:ffffc90000167890 EFLAGS: 00000202
RAX: 1ffffffff3275e00 RBX: 00000000000003fd RCX: 0000000000000000
RDX: 00000000000003fd RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffffff993af890 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: ffffffff853f3a60 R12: dffffc0000000000
R13: 0000000000000000 R14: ffffffff993af600 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff8881269bb000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f8787af9000 CR3: 000000008cbbc000 CR4: 00000000003526f0
Call Trace:
<TASK>
serial_in drivers/tty/serial/8250/8250.h:137 [inline]
serial_lsr_in drivers/tty/serial/8250/8250.h:159 [inline]
wait_for_lsr+0x1aa/0x2f0 drivers/tty/serial/8250/8250_port.c:1984
fifo_wait_for_lsr drivers/tty/serial/8250/8250_port.c:3288 [inline]
serial8250_console_fifo_write drivers/tty/serial/8250/8250_port.c:3311 [inline]
serial8250_console_write+0x11bd/0x1b40 drivers/tty/serial/8250/8250_port.c:3396
console_emit_next_record kernel/printk/printk.c:3118 [inline]
console_flush_all+0x698/0xcd0 kernel/printk/printk.c:3226
__console_flush_and_unlock+0xa4/0x240 kernel/printk/printk.c:3285
legacy_kthread_func+0x13b/0x1a0 kernel/printk/printk.c:3638
kthread+0x711/0x8a0 kernel/kthread.c:463
ret_from_fork+0x436/0x7d0 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>


Tested on:

commit: fec734e8 Merge tag 'riscv-for-linus-v6.17-rc8' of git:..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15493d34580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f5b21423ca3f0a96
dashboard link: https://syzkaller.appspot.com/bug?extid=cb91f22d8a581fc19edf
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=161d3142580000

syzbot

unread,
Sep 27, 2025, 3:25:49 AMSep 27
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: [PATCH] bcachefs: Fix deadlocks between fallocate and readahead
There are ABBA deadlocks between fallocate and readahead operations
at two locations in __bchfs_fallocate():

Thread 1 (fallocate):
bch2_fallocate_dispatch
inode_lock(&inode->v)
bch2_pagecache_block_get(inode) // Acquires two_state_lock
__bchfs_fallocate
bch2_clamp_data_hole (or bch2_mark_pagecache_reserved)
bch2_seek_pagecache_hole
__filemap_get_folio
folio_lock() // BLOCKS - Thread 2 holds it

Thread 2 (readahead via copy_file_range):
bch2_readahead
folio_lock() // Holds page lock
__bch2_two_state_lock(&pagecache_lock) // BLOCKS - Thread 1 holds it

The issue is that drop_locks_do() only releases btree transaction locks,
but Thread 2 is blocked waiting for the two_state_lock (pagecache_block)
held by bch2_pagecache_block_get().

Fix by explicitly releasing and re-acquiring the pagecache_block lock
around both blocking operations (bch2_clamp_data_hole and
bch2_mark_pagecache_reserved), following the same pattern used in
bch2_page_fault(). Force a transaction restart after lock release to
ensure consistency.

Reported-by: syzbot+cb91f2...@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=cb91f22d8a581fc19edf
Signed-off-by: Deepanshu Kartikey <Karti...@gmail.com>
---
fs/bcachefs/fs-io.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index a233f45875e9..66a60e5f03fc 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -694,13 +694,19 @@ static noinline int __bchfs_fallocate(struct bch_inode_info *inode, int mode,
&hole_start,
&hole_end,
opts.data_replicas, true)) {
+ /* Release pagecache_block to prevent deadlock with readahead */
+ bch2_pagecache_block_put(inode);
ret = drop_locks_do(trans,
(bch2_clamp_data_hole(&inode->v,
&hole_start,
&hole_end,
opts.data_replicas, false), 0));
+ bch2_pagecache_block_get(inode);
if (ret)
goto bkey_err;
+ /* Force transaction restart to revalidate state */
+ ret = -BCH_ERR_transaction_restart;
+ goto bkey_err;
}
bch2_btree_iter_set_pos(trans, &iter, POS(iter.pos.inode, hole_start));

@@ -730,11 +736,17 @@ static noinline int __bchfs_fallocate(struct bch_inode_info *inode, int mode,

if (bch2_mark_pagecache_reserved(inode, &hole_start,
iter.pos.offset, true)) {
+ /* Release pagecache_block to prevent deadlock */
+ bch2_pagecache_block_put(inode);
+
ret = drop_locks_do(trans,
bch2_mark_pagecache_reserved(inode, &hole_start,
iter.pos.offset, false));
+ bch2_pagecache_block_get(inode);
if (ret)
goto bkey_err;
+ ret = -BCH_ERR_transaction_restart;
+ goto bkey_err;
}
bkey_err:
bch2_quota_reservation_put(c, inode, &quota_res);
--
2.43.0

syzbot

unread,
Sep 27, 2025, 3:25:49 AMSep 27
to linux-...@vger.kernel.org, syzkall...@googlegroups.com

syzbot

unread,
Sep 27, 2025, 3:49:05 AMSep 27
to =sy...@syzkaller.appspotmail.com, karti...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+cb91f2...@syzkaller.appspotmail.com
Tested-by: syzbot+cb91f2...@syzkaller.appspotmail.com

Tested on:

commit: fec734e8 Merge tag 'riscv-for-linus-v6.17-rc8' of git:..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17339f12580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f5b21423ca3f0a96
dashboard link: https://syzkaller.appspot.com/bug?extid=cb91f22d8a581fc19edf
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=12dde2e2580000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Oct 24, 2025, 11:55:05 PM (14 hours ago) Oct 24
to =sy...@syzkaller.appspotmail.com, karti...@gmail.com, kent.ov...@linux.dev, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, torv...@linux-foundation.org
syzbot suspects this issue was fixed by commit:

commit f2c61db29f277b9c80de92102fc532cc247495cd
Author: Linus Torvalds <torv...@linux-foundation.org>
Date: Mon Sep 29 20:43:52 2025 +0000

Remove bcachefs core code

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13ba53e2580000
start commit: 5aca7966d2a7 Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10052e42580000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: Remove bcachefs core code
Reply all
Reply to author
Forward
0 new messages