syzbot


KASAN: slab-use-after-free Read in add_ra_bio_pages (2)

Status: auto-obsoleted due to no activity on 2024/03/09 20:05
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+e91486f74874aaef3961@syzkaller.appspotmail.com
First crash: 204d, last: 204d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in add_ra_bio_pages btrfs 1 429d 425d 0/27 auto-obsoleted due to no activity on 2023/07/28 17:29
upstream KASAN: slab-use-after-free Read in add_ra_bio_pages (3) btrfs 1 9d11h 5d11h 0/27 moderation: reported on 2024/06/26 23:50

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in add_ra_bio_pages+0x788/0xc10 fs/btrfs/compression.c:435
Read of size 8 at addr ffff888078db4018 by task syz-executor.2/17406

CPU: 1 PID: 17406 Comm: syz-executor.2 Not tainted 6.7.0-rc4-syzkaller-00424-gc527f5606aa5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:475
 kasan_report+0x142/0x170 mm/kasan/report.c:588
 add_ra_bio_pages+0x788/0xc10 fs/btrfs/compression.c:435
 btrfs_submit_compressed_read+0x655/0xa40 fs/btrfs/compression.c:522
 submit_one_bio+0xfc/0x1c0 fs/btrfs/extent_io.c:119
 extent_readahead+0x1323/0x1470 fs/btrfs/extent_io.c:2254
 read_pages+0x183/0x830 mm/readahead.c:160
 page_cache_ra_unbounded+0x186/0x7c0 mm/readahead.c:241
 page_cache_sync_readahead include/linux/pagemap.h:1283 [inline]
 filemap_get_pages+0x49c/0x2080 mm/filemap.c:2497
 filemap_read+0x41b/0xec0 mm/filemap.c:2593
 call_read_iter include/linux/fs.h:2014 [inline]
 copy_splice_read+0x4c9/0x9c0 fs/splice.c:364
 splice_direct_to_actor+0x2c4/0x9e0 fs/splice.c:1069
 do_splice_direct+0x2ac/0x3f0 fs/splice.c:1194
 do_sendfile+0x62c/0x1000 fs/read_write.c:1254
 __do_sys_sendfile64 fs/read_write.c:1322 [inline]
 __se_sys_sendfile64+0x17c/0x1e0 fs/read_write.c:1308
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0x45/0x110 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f4bae47cba9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4baf1490c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00007f4bae59bf80 RCX: 00007f4bae47cba9
RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000004
RBP: 00007f4bae4c847a R08: 0000000000000000 R09: 0000000000000000
R10: 0001000000201005 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f4bae59bf80 R15: 00007ffc24548f38
 </TASK>

Allocated by task 42:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x66/0x70 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6c/0x3c0 mm/slab.h:763
 slab_alloc_node mm/slub.c:3478 [inline]
 slab_alloc mm/slub.c:3486 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
 kmem_cache_alloc+0x19e/0x2b0 mm/slub.c:3502
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 alloc_extent_map+0x21/0x130 fs/btrfs/extent_map.c:49
 create_io_em fs/btrfs/inode.c:7249 [inline]
 submit_one_async_extent fs/btrfs/inode.c:1148 [inline]
 submit_compressed_extents+0x8bf/0x1a50 fs/btrfs/inode.c:1604
 run_ordered_work fs/btrfs/async-thread.c:246 [inline]
 btrfs_work_helper+0x542/0xbe0 fs/btrfs/async-thread.c:325
 process_one_work kernel/workqueue.c:2627 [inline]
 process_scheduled_works+0x90f/0x1420 kernel/workqueue.c:2700
 worker_thread+0xa5f/0x1000 kernel/workqueue.c:2781
 kthread+0x2d3/0x370 kernel/kthread.c:388
 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242

Freed by task 17406:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:164 [inline]
 slab_free_hook mm/slub.c:1800 [inline]
 slab_free_freelist_hook mm/slub.c:1826 [inline]
 slab_free mm/slub.c:3809 [inline]
 kmem_cache_free+0x299/0x470 mm/slub.c:3831
 add_ra_bio_pages+0x6ed/0xc10 fs/btrfs/compression.c:423
 btrfs_submit_compressed_read+0x655/0xa40 fs/btrfs/compression.c:522
 submit_one_bio+0xfc/0x1c0 fs/btrfs/extent_io.c:119
 extent_readahead+0x1323/0x1470 fs/btrfs/extent_io.c:2254
 read_pages+0x183/0x830 mm/readahead.c:160
 page_cache_ra_unbounded+0x186/0x7c0 mm/readahead.c:241
 page_cache_sync_readahead include/linux/pagemap.h:1283 [inline]
 filemap_get_pages+0x49c/0x2080 mm/filemap.c:2497
 filemap_read+0x41b/0xec0 mm/filemap.c:2593
 call_read_iter include/linux/fs.h:2014 [inline]
 copy_splice_read+0x4c9/0x9c0 fs/splice.c:364
 splice_direct_to_actor+0x2c4/0x9e0 fs/splice.c:1069
 do_splice_direct+0x2ac/0x3f0 fs/splice.c:1194
 do_sendfile+0x62c/0x1000 fs/read_write.c:1254
 __do_sys_sendfile64 fs/read_write.c:1322 [inline]
 __se_sys_sendfile64+0x17c/0x1e0 fs/read_write.c:1308
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0x45/0x110 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

The buggy address belongs to the object at ffff888078db4000
 which belongs to the cache btrfs_extent_map of size 144
The buggy address is located 24 bytes inside of
 freed 144-byte region [ffff888078db4000, ffff888078db4090)

The buggy address belongs to the physical page:
page:ffffea0001e36d00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78db4
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000800 ffff88814c553500 ffffea000051b280 0000000000000002
raw: 0000000000000000 0000000080130013 00000001ffffffff 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 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 10284, tgid 10227 (syz-executor.2), ts 368375511382, free_ts 368351738690
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1537
 prep_new_page mm/page_alloc.c:1544 [inline]
 get_page_from_freelist+0x33ea/0x3570 mm/page_alloc.c:3312
 __alloc_pages+0x255/0x680 mm/page_alloc.c:4568
 alloc_pages_mpol+0x3de/0x640 mm/mempolicy.c:2133
 alloc_slab_page+0x6a/0x170 mm/slub.c:1870
 allocate_slab mm/slub.c:2017 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2070
 ___slab_alloc+0xc8a/0x1330 mm/slub.c:3223
 __slab_alloc mm/slub.c:3322 [inline]
 __slab_alloc_node mm/slub.c:3375 [inline]
 slab_alloc_node mm/slub.c:3468 [inline]
 slab_alloc mm/slub.c:3486 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
 kmem_cache_alloc+0x1e9/0x2b0 mm/slub.c:3502
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 alloc_extent_map fs/btrfs/extent_map.c:49 [inline]
 btrfs_drop_extent_map_range+0x32c/0x15e0 fs/btrfs/extent_map.c:737
 btrfs_replace_extent_map_range+0xfc/0x170 fs/btrfs/extent_map.c:954
 btrfs_cont_expand+0x803/0xce0 fs/btrfs/inode.c:4923
 btrfs_write_check+0x447/0x500 fs/btrfs/file.c:1171
 btrfs_direct_write fs/btrfs/file.c:1501 [inline]
 btrfs_do_write_iter+0x5fe/0x1190 fs/btrfs/file.c:1684
 do_iter_readv_writev+0x330/0x4a0
 do_iter_write+0x1f6/0x8d0 fs/read_write.c:860
 iter_file_splice_write+0x86d/0x1010 fs/splice.c:736
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1137 [inline]
 free_unref_page_prepare+0x931/0xa60 mm/page_alloc.c:2347
 free_unref_page_list+0x5a0/0x840 mm/page_alloc.c:2533
 release_pages+0x2117/0x2400 mm/swap.c:1042
 __folio_batch_release+0x84/0x100 mm/swap.c:1062
 folio_batch_release include/linux/pagevec.h:83 [inline]
 invalidate_inode_pages2_range+0xd9a/0x1040 mm/truncate.c:679
 close_ctree+0x65c/0xd40 fs/btrfs/disk-io.c:4373
 generic_shutdown_super+0x13a/0x2c0 fs/super.c:696
 kill_anon_super+0x3b/0x70 fs/super.c:1295
 btrfs_kill_super+0x41/0x50 fs/btrfs/super.c:2100
 deactivate_locked_super+0xc1/0x130 fs/super.c:484
 cleanup_mnt+0x426/0x4c0 fs/namespace.c:1256
 task_work_run+0x24a/0x300 kernel/task_work.c:180
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:171
 exit_to_user_mode_prepare+0xb1/0x150 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x69/0x2a0 kernel/entry/common.c:296
 do_syscall_64+0x52/0x110 arch/x86/entry/common.c:89

Memory state around the buggy address:
 ffff888078db3f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888078db3f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888078db4000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888078db4080: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb
 ffff888078db4100: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/12/10 20:04 upstream c527f5606aa5 28b24332 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in add_ra_bio_pages
* Struck through repros no longer work on HEAD.