syzbot


KASAN: slab-use-after-free Read in add_ra_bio_pages

Status: auto-obsoleted due to no activity on 2023/07/28 17:29
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+f06304d8e679318dc253@syzkaller.appspotmail.com
First crash: 334d, last: 334d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in add_ra_bio_pages (2) btrfs 1 109d 105d 0/26 auto-obsoleted due to no activity on 2024/03/09 20:05

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in add_ra_bio_pages.isra.0+0xdb0/0xe30 fs/btrfs/compression.c:443
Read of size 8 at addr ffff8880002b4398 by task syz-executor.1/5252

CPU: 0 PID: 5252 Comm: syz-executor.1 Not tainted 6.3.0-syzkaller-11025-g89d77f71f493 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351
 print_report mm/kasan/report.c:462 [inline]
 kasan_report+0x11c/0x130 mm/kasan/report.c:572
 add_ra_bio_pages.isra.0+0xdb0/0xe30 fs/btrfs/compression.c:443
 btrfs_submit_compressed_read+0x58f/0xa40 fs/btrfs/compression.c:530
 submit_one_bio+0x228/0x3f0 fs/btrfs/extent_io.c:151
 extent_readahead+0x11c4/0x1440 fs/btrfs/extent_io.c:2623
 read_pages+0x1a2/0xd40 mm/readahead.c:161
 page_cache_ra_unbounded+0x2f7/0x5e0 mm/readahead.c:242
 do_page_cache_ra mm/readahead.c:300 [inline]
 page_cache_ra_order+0x6ec/0xa00 mm/readahead.c:560
 do_sync_mmap_readahead mm/filemap.c:3187 [inline]
 filemap_fault+0x140a/0x24a0 mm/filemap.c:3279
 __do_fault+0x107/0x600 mm/memory.c:4176
 do_read_fault mm/memory.c:4530 [inline]
 do_fault mm/memory.c:4659 [inline]
 do_pte_missing mm/memory.c:3647 [inline]
 handle_pte_fault mm/memory.c:4947 [inline]
 __handle_mm_fault+0x28bc/0x41c0 mm/memory.c:5089
 handle_mm_fault+0x2af/0x9f0 mm/memory.c:5243
 faultin_page mm/gup.c:925 [inline]
 __get_user_pages+0x614/0x10e0 mm/gup.c:1147
 populate_vma_page_range+0x2df/0x420 mm/gup.c:1543
 __mm_populate+0x105/0x3b0 mm/gup.c:1652
 mm_populate include/linux/mm.h:3153 [inline]
 vm_mmap_pgoff+0x2c2/0x3b0 mm/util.c:548
 ksys_mmap_pgoff+0x41f/0x5a0 mm/mmap.c:1440
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f0ad708c169
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0ad7e79168 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f0ad71ac120 RCX: 00007f0ad708c169
RDX: 000000000000000b RSI: 0000000000b36000 RDI: 0000000020000000
RBP: 00007f0ad70e7ca1 R08: 0000000000000007 R09: 0000000000000000
R10: 0000000000028011 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc440b5cef R14: 00007f0ad7e79300 R15: 0000000000022000
 </TASK>

Allocated by task 74:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 __kasan_slab_alloc+0x7f/0x90 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook mm/slab.h:711 [inline]
 slab_alloc_node mm/slab.c:3256 [inline]
 slab_alloc mm/slab.c:3265 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3442 [inline]
 kmem_cache_alloc+0x1bd/0x3f0 mm/slab.c:3451
 kmem_cache_zalloc include/linux/slab.h:670 [inline]
 alloc_extent_map fs/btrfs/extent_map.c:49 [inline]
 btrfs_drop_extent_map_range+0x129/0x16d0 fs/btrfs/extent_map.c:734
 btrfs_replace_extent_map_range+0x106/0x1b0 fs/btrfs/extent_map.c:954
 create_io_em+0x1c8/0x2c0 fs/btrfs/inode.c:7250
 cow_file_range+0x46e/0xd30 fs/btrfs/inode.c:1300
 submit_uncompressed_range fs/btrfs/inode.c:945 [inline]
 submit_one_async_extent fs/btrfs/inode.c:1004 [inline]
 submit_compressed_extents+0x837/0xcc0 fs/btrfs/inode.c:1110
 async_cow_submit+0xa1/0x170 fs/btrfs/inode.c:1500
 run_ordered_work fs/btrfs/async-thread.c:211 [inline]
 btrfs_work_helper+0x2a9/0xd80 fs/btrfs/async-thread.c:290
 process_one_work+0x991/0x15c0 kernel/workqueue.c:2390
 worker_thread+0x669/0x1090 kernel/workqueue.c:2537
 kthread+0x344/0x440 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

Freed by task 5252:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:162 [inline]
 __cache_free mm/slab.c:3389 [inline]
 __do_kmem_cache_free mm/slab.c:3576 [inline]
 kmem_cache_free mm/slab.c:3601 [inline]
 kmem_cache_free+0x105/0x370 mm/slab.c:3594
 free_extent_map fs/btrfs/extent_map.c:72 [inline]
 free_extent_map+0x147/0x1e0 fs/btrfs/extent_map.c:63
 add_ra_bio_pages.isra.0+0x765/0xe30 fs/btrfs/compression.c:431
 btrfs_submit_compressed_read+0x58f/0xa40 fs/btrfs/compression.c:530
 submit_one_bio+0x228/0x3f0 fs/btrfs/extent_io.c:151
 extent_readahead+0x11c4/0x1440 fs/btrfs/extent_io.c:2623
 read_pages+0x1a2/0xd40 mm/readahead.c:161
 page_cache_ra_unbounded+0x2f7/0x5e0 mm/readahead.c:242
 do_page_cache_ra mm/readahead.c:300 [inline]
 page_cache_ra_order+0x6ec/0xa00 mm/readahead.c:560
 do_sync_mmap_readahead mm/filemap.c:3187 [inline]
 filemap_fault+0x140a/0x24a0 mm/filemap.c:3279
 __do_fault+0x107/0x600 mm/memory.c:4176
 do_read_fault mm/memory.c:4530 [inline]
 do_fault mm/memory.c:4659 [inline]
 do_pte_missing mm/memory.c:3647 [inline]
 handle_pte_fault mm/memory.c:4947 [inline]
 __handle_mm_fault+0x28bc/0x41c0 mm/memory.c:5089
 handle_mm_fault+0x2af/0x9f0 mm/memory.c:5243
 faultin_page mm/gup.c:925 [inline]
 __get_user_pages+0x614/0x10e0 mm/gup.c:1147
 populate_vma_page_range+0x2df/0x420 mm/gup.c:1543
 __mm_populate+0x105/0x3b0 mm/gup.c:1652
 mm_populate include/linux/mm.h:3153 [inline]
 vm_mmap_pgoff+0x2c2/0x3b0 mm/util.c:548
 ksys_mmap_pgoff+0x41f/0x5a0 mm/mmap.c:1440
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

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

The buggy address belongs to the physical page:
page:ffffea000000ad00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2b4
flags: 0x7ff00000000200(slab|node=0|zone=0|lastcpupid=0x7ff)
page_type: 0x13()
raw: 007ff00000000200 ffff888048384a00 ffffea0000009050 ffff888013b59a50
raw: 0000000000000000 ffff8880002b4040 0000000100000013 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 0x242040(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 1079, tgid 1079 (kworker/u17:5), ts 224591757138, free_ts 224280003183
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1722
 prep_new_page mm/page_alloc.c:1729 [inline]
 get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3493
 __alloc_pages_slowpath.constprop.0+0x2e7/0x2170 mm/page_alloc.c:4293
 __alloc_pages+0x408/0x4a0 mm/page_alloc.c:4772
 __alloc_pages_node include/linux/gfp.h:237 [inline]
 kmem_getpages mm/slab.c:1360 [inline]
 cache_grow_begin+0x9b/0x3b0 mm/slab.c:2569
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942
 ____cache_alloc mm/slab.c:3018 [inline]
 ____cache_alloc mm/slab.c:3001 [inline]
 __do_cache_alloc mm/slab.c:3201 [inline]
 slab_alloc_node mm/slab.c:3249 [inline]
 slab_alloc mm/slab.c:3265 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3442 [inline]
 kmem_cache_alloc+0x397/0x3f0 mm/slab.c:3451
 kmem_cache_zalloc include/linux/slab.h:670 [inline]
 alloc_extent_map fs/btrfs/extent_map.c:49 [inline]
 btrfs_drop_extent_map_range+0x239/0x16d0 fs/btrfs/extent_map.c:735
 btrfs_replace_extent_map_range+0x106/0x1b0 fs/btrfs/extent_map.c:954
 create_io_em+0x1c8/0x2c0 fs/btrfs/inode.c:7250
 submit_one_async_extent fs/btrfs/inode.c:1025 [inline]
 submit_compressed_extents+0x62f/0xcc0 fs/btrfs/inode.c:1110
 async_cow_submit+0xa1/0x170 fs/btrfs/inode.c:1500
 run_ordered_work fs/btrfs/async-thread.c:211 [inline]
 btrfs_work_helper+0x2a9/0xd80 fs/btrfs/async-thread.c:290
 process_one_work+0x991/0x15c0 kernel/workqueue.c:2390
 worker_thread+0x669/0x1090 kernel/workqueue.c:2537
 kthread+0x344/0x440 kernel/kthread.c:379
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1302 [inline]
 free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2555
 free_unref_page+0x33/0x370 mm/page_alloc.c:2650
 slab_destroy mm/slab.c:1612 [inline]
 slabs_destroy+0x85/0xc0 mm/slab.c:1632
 cache_flusharray mm/slab.c:3360 [inline]
 ___cache_free+0x2ae/0x3d0 mm/slab.c:3423
 qlink_free mm/kasan/quarantine.c:166 [inline]
 qlist_free_all+0x4f/0x1a0 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook mm/slab.h:711 [inline]
 slab_alloc_node mm/slab.c:3256 [inline]
 kmem_cache_alloc_node+0x296/0x510 mm/slab.c:3528
 __alloc_skb+0x288/0x330 net/core/skbuff.c:644
 alloc_skb include/linux/skbuff.h:1288 [inline]
 alloc_skb_with_frags+0x9a/0x6c0 net/core/skbuff.c:6370
 sock_alloc_send_pskb+0x7a7/0x930 net/core/sock.c:2729
 sock_alloc_send_skb include/net/sock.h:1860 [inline]
 mld_newpack.isra.0+0x1b9/0x760 net/ipv6/mcast.c:1748
 add_grhead+0x295/0x340 net/ipv6/mcast.c:1851
 add_grec+0x1053/0x1610 net/ipv6/mcast.c:1989
 mld_send_initial_cr.part.0+0xe7/0x260 net/ipv6/mcast.c:2236
 mld_send_initial_cr net/ipv6/mcast.c:1232 [inline]
 mld_dad_work+0x1d7/0x680 net/ipv6/mcast.c:2262

Memory state around the buggy address:
 ffff8880002b4280: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
 ffff8880002b4300: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880002b4380: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff8880002b4400: fb fb fc fc fc fc fc fc fc fc 00 00 00 00 00 00
 ffff8880002b4480: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/04/29 17:29 upstream 89d77f71f493 62df2017 .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in add_ra_bio_pages
* Struck through repros no longer work on HEAD.