linux-bcachefs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_copygc
@ 2025-07-08 14:04 syzbot
  2025-07-08 14:41 ` syzbot
  2025-07-09 19:34 ` syzbot
  0 siblings, 2 replies; 3+ messages in thread
From: syzbot @ 2025-07-08 14:04 UTC (permalink / raw)
  To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    4c06e63b9203 Merge tag 'for-6.16-rc4-tag' of git://git.ker..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10487ebc580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b29b1a0d7330d4a8
dashboard link: https://syzkaller.appspot.com/bug?extid=3168625f36f4a539237e
compiler:       Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-4c06e63b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ff61efc838cb/vmlinux-4c06e63b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/dea44d0d14bb/bzImage-4c06e63b.xz

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

bcachefs (loop0): Detected missing backpointers in bucket 34, now have 1/128 with missing
  running recovery pass check_extents_to_backpointers (17), currently at check_inodes (28)
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read include/linux/instrumented.h:68 [inline]
BUG: KASAN: slab-use-after-free in _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
BUG: KASAN: slab-use-after-free in bch2_bucket_bitmap_test fs/bcachefs/backpointers.h:194 [inline]
BUG: KASAN: slab-use-after-free in bch2_bucket_is_movable fs/bcachefs/movinggc.c:78 [inline]
BUG: KASAN: slab-use-after-free in bch2_copygc_get_buckets fs/bcachefs/movinggc.c:157 [inline]
BUG: KASAN: slab-use-after-free in bch2_copygc+0xfb1/0x4380 fs/bcachefs/movinggc.c:221
Read of size 8 at addr ffff888055be7920 by task bch-copygc/loop/5355

CPU: 0 UID: 0 PID: 5355 Comm: bch-copygc/loop Not tainted 6.16.0-rc4-syzkaller-00123-g4c06e63b9203 #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_address_description mm/kasan/report.c:408 [inline]
 print_report+0xd2/0x2b0 mm/kasan/report.c:521
 kasan_report+0x118/0x150 mm/kasan/report.c:634
 check_region_inline mm/kasan/generic.c:-1 [inline]
 kasan_check_range+0x2b0/0x2c0 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:68 [inline]
 _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
 bch2_bucket_bitmap_test fs/bcachefs/backpointers.h:194 [inline]
 bch2_bucket_is_movable fs/bcachefs/movinggc.c:78 [inline]
 bch2_copygc_get_buckets fs/bcachefs/movinggc.c:157 [inline]
 bch2_copygc+0xfb1/0x4380 fs/bcachefs/movinggc.c:221
 bch2_copygc_thread+0x97a/0xe00 fs/bcachefs/movinggc.c:409
 kthread+0x70e/0x8a0 kernel/kthread.c:464
 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Allocated by task 5355:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:260 [inline]
 __do_kmalloc_node mm/slub.c:4328 [inline]
 __kvmalloc_node_noprof+0x30d/0x5f0 mm/slub.c:5015
 kvmalloc_array_node_noprof include/linux/slab.h:1065 [inline]
 bch2_bucket_bitmap_set+0x9a/0x1a0 fs/bcachefs/backpointers.c:1351
 check_bucket_backpointer_mismatch+0x1bdf/0x23a0 fs/bcachefs/backpointers.c:964
 check_bucket_backpointer_pos_mismatch fs/bcachefs/backpointers.c:1193 [inline]
 bch2_check_bucket_backpointer_mismatch+0x36c/0x690 fs/bcachefs/backpointers.c:1205
 __bch2_move_data_phys+0x17a7/0x1c50 fs/bcachefs/move.c:922
 bch2_evacuate_bucket+0x228/0x3a0 fs/bcachefs/move.c:1082
 bch2_copygc+0x3a89/0x4380 fs/bcachefs/movinggc.c:234
 bch2_copygc_thread+0x97a/0xe00 fs/bcachefs/movinggc.c:409
 kthread+0x70e/0x8a0 kernel/kthread.c:464
 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

The buggy address belongs to the object at ffff888055be7920
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
 freed 16-byte region [ffff888055be7920, ffff888055be7930)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x55be7
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88801a441640 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080800080 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5319, tgid 5319 (kworker/u5:2), ts 78159391425, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1704
 prep_new_page mm/page_alloc.c:1712 [inline]
 get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3669
 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4959
 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2419
 alloc_slab_page mm/slub.c:2451 [inline]
 allocate_slab+0x8a/0x3b0 mm/slub.c:2619
 new_slab mm/slub.c:2673 [inline]
 ___slab_alloc+0xbfc/0x1480 mm/slub.c:3859
 __slab_alloc mm/slub.c:3949 [inline]
 __slab_alloc_node mm/slub.c:4024 [inline]
 slab_alloc_node mm/slub.c:4185 [inline]
 __do_kmalloc_node mm/slub.c:4327 [inline]
 __kmalloc_node_track_caller_noprof+0x2f8/0x4e0 mm/slub.c:4347
 __do_krealloc mm/slub.c:4905 [inline]
 krealloc_noprof+0x124/0x340 mm/slub.c:4958
 bch2_printbuf_make_room+0x1f5/0x360 fs/bcachefs/printbuf.c:59
 bch2_prt_printf+0x282/0x740 fs/bcachefs/printbuf.c:186
 bch2_sb_validate+0xf73/0x1980 fs/bcachefs/super-io.c:514
 bch2_write_super+0xd68/0x2d30 fs/bcachefs/super-io.c:1089
 bch2_mark_replicas_slowpath+0x2e1/0x580 fs/bcachefs/replicas.c:338
 bch2_journal_write+0x49ab/0x5570 fs/bcachefs/journal_io.c:2208
 process_one_work kernel/workqueue.c:3238 [inline]
 process_scheduled_works+0xade/0x17b0 kernel/workqueue.c:3321
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3402
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888055be7800: fa fb fc fc 00 00 fc fc 00 00 fc fc fa fb fc fc
 ffff888055be7880: fa fb fc fc 00 00 fc fc 00 00 fc fc fa fb fc fc
>ffff888055be7900: fa fb fc fc fb fb fc fc 00 00 fc fc fa fb fc fc
                               ^
 ffff888055be7980: fa fb fc fc fa fb fc fc fa fb fc fc 00 00 fc fc
 ffff888055be7a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
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 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] 3+ messages in thread

* Re: [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_copygc
  2025-07-08 14:04 [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_copygc syzbot
@ 2025-07-08 14:41 ` syzbot
  2025-07-09 19:34 ` syzbot
  1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2025-07-08 14:41 UTC (permalink / raw)
  To: anna.luese, kent.overstreet, linux-bcachefs, linux-kernel,
	syzkaller-bugs

syzbot has found a reproducer for the following issue on:

HEAD commit:    7482bb149b9f Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=12bf4a8c580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=3c06e3e2454512b3
dashboard link: https://syzkaller.appspot.com/bug?extid=3168625f36f4a539237e
compiler:       Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14f63f70580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16bf4a8c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f623d741d651/disk-7482bb14.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/483e23ae71b1/vmlinux-7482bb14.xz
kernel image: https://storage.googleapis.com/syzbot-assets/79b5baaa1b50/Image-7482bb14.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/f9688b789a98/mount_0.gz

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

bcachefs (loop1): Detected missing backpointers in bucket 34, now have 1/128 with missing
Unable to handle kernel paging request at virtual address ffff60021a145c30
KASAN: probably wild-memory-access in range [0xffff0010d0a2e180-0xffff0010d0a2e187]
Mem abort info:
  ESR = 0x0000000096000005
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x05: level 1 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000207144000
[ffff60021a145c30] pgd=0000000000000000, p4d=000000023397b003, pud=0000000000000000
Internal error: Oops: 0000000096000005 [#1]  SMP
Modules linked in:
CPU: 0 UID: 0 PID: 6717 Comm: bch-copygc/loop Not tainted 6.16.0-rc4-syzkaller-g7482bb149b9f #0 PREEMPT 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : generic_test_bit include/asm-generic/bitops/generic-non-atomic.h:128 [inline]
pc : bch2_bucket_bitmap_test fs/bcachefs/backpointers.h:194 [inline]
pc : bch2_bucket_is_movable fs/bcachefs/movinggc.c:78 [inline]
pc : bch2_copygc_get_buckets fs/bcachefs/movinggc.c:157 [inline]
pc : bch2_copygc+0xab4/0x3460 fs/bcachefs/movinggc.c:221
lr : rcu_read_unlock include/linux/rcupdate.h:873 [inline]
lr : class_rcu_destructor include/linux/rcupdate.h:1155 [inline]
lr : bch2_dev_tryget_noerror fs/bcachefs/sb-members.h:241 [inline]
lr : bch2_dev_tryget fs/bcachefs/sb-members.h:245 [inline]
lr : bch2_bucket_is_movable fs/bcachefs/movinggc.c:74 [inline]
lr : bch2_copygc_get_buckets fs/bcachefs/movinggc.c:157 [inline]
lr : bch2_copygc+0xa7c/0x3460 fs/bcachefs/movinggc.c:221
sp : ffff80009e0c74c0
x29: ffff80009e0c7920 x28: 0000008000000022 x27: ffff80009e0c76c8
x26: dfff800000000000 x25: ffff80009e0c7cf8 x24: 0000000000000000
x23: ffff0000f5890000 x22: 0000000000000000 x21: ffff0000f2d00000
x20: ffff0010d0a2e180
 x19: ffff0000df09cc28 x18: 00000000ffffffff
x17: ffff800093363000 x16: ffff80008aefcb18 x15: 0000000000000001
x14: 1fffe0001eb12008 x13: 0000000000000000 x12: 0000000000000000
x11: ffff60001eb12009 x10: 0000000000ff0100 x9 : 0000001000000000
x8 : 1fffe0021a145c30 x7 : ffff800082a0df54 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff800082a0edd4
x2 : 0000000000000001 x1 : 0000000000000080 x0 : ffff0000cc76bd00
Call trace:
 generic_test_bit include/asm-generic/bitops/generic-non-atomic.h:128 [inline] (P)
 bch2_bucket_bitmap_test fs/bcachefs/backpointers.h:194 [inline] (P)
 bch2_bucket_is_movable fs/bcachefs/movinggc.c:78 [inline] (P)
 bch2_copygc_get_buckets fs/bcachefs/movinggc.c:157 [inline] (P)
 bch2_copygc+0xab4/0x3460 fs/bcachefs/movinggc.c:221 (P)
 bch2_copygc_thread+0x898/0xd8c fs/bcachefs/movinggc.c:409
 kthread+0x5fc/0x75c kernel/kthread.c:464
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:847
Code: d343fd29 927da529 8b090114 d343fe88 (387a6908) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	d343fd29 	lsr	x9, x9, #3
   4:	927da529 	and	x9, x9, #0x1ffffffffff8
   8:	8b090114 	add	x20, x8, x9
   c:	d343fe88 	lsr	x8, x20, #3
* 10:	387a6908 	ldrb	w8, [x8, x26] <-- trapping instruction


---
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.

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

* Re: [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_copygc
  2025-07-08 14:04 [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_copygc syzbot
  2025-07-08 14:41 ` syzbot
@ 2025-07-09 19:34 ` syzbot
  1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2025-07-09 19:34 UTC (permalink / raw)
  To: anna.luese, kent.overstreet, linux-bcachefs, linux-kernel,
	syzkaller-bugs

syzbot has bisected this issue to:

commit 82067c916994dd1bfec65496144dc16e17899e36
Author: Kent Overstreet <kent.overstreet@linux.dev>
Date:   Fri May 9 03:21:28 2025 +0000

    bcachefs: buckets_in_flight on stack

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=10d6aa8c580000
start commit:   d006330be3f7 Merge tag 'sound-6.16-rc6' of git://git.kerne..
git tree:       upstream
final oops:     https://syzkaller.appspot.com/x/report.txt?x=12d6aa8c580000
console output: https://syzkaller.appspot.com/x/log.txt?x=14d6aa8c580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=bd2783a0a99d4ed0
dashboard link: https://syzkaller.appspot.com/bug?extid=3168625f36f4a539237e
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=175fabd4580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14c0bf70580000

Reported-by: syzbot+3168625f36f4a539237e@syzkaller.appspotmail.com
Fixes: 82067c916994 ("bcachefs: buckets_in_flight on stack")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

end of thread, other threads:[~2025-07-09 19:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 14:04 [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_copygc syzbot
2025-07-08 14:41 ` syzbot
2025-07-09 19:34 ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).