syzbot


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

Status: auto-obsoleted due to no activity on 2023/09/08 05:39
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+5927b00bae2996410ad4@syzkaller.appspotmail.com
First crash: 387d, last: 362d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [btrfs?] KASAN: slab-use-after-free Read in __btrfs_release_delayed_node 0 (1) 2023/05/10 06:56

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read include/linux/instrumented.h:68 [inline]
BUG: KASAN: slab-use-after-free in atomic_long_read include/linux/atomic/atomic-instrumented.h:1309 [inline]
BUG: KASAN: slab-use-after-free in __mutex_unlock_slowpath+0xef/0x750 kernel/locking/mutex.c:916
Read of size 8 at addr ffff88802bf9fb78 by task syz-executor.3/5023

CPU: 0 PID: 5023 Comm: syz-executor.3 Not tainted 6.4.0-rc4-syzkaller-00047-gafead42fdfca #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/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:351 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:462
 kasan_report+0x176/0x1b0 mm/kasan/report.c:572
 kasan_check_range+0x283/0x290 mm/kasan/generic.c:187
 instrument_atomic_read include/linux/instrumented.h:68 [inline]
 atomic_long_read include/linux/atomic/atomic-instrumented.h:1309 [inline]
 __mutex_unlock_slowpath+0xef/0x750 kernel/locking/mutex.c:916
 __btrfs_release_delayed_node+0x8a1/0xaa0 fs/btrfs/delayed-inode.c:261
 btrfs_evict_inode+0x72e/0x1010 fs/btrfs/inode.c:5336
 evict+0x2a4/0x620 fs/inode.c:665
 dispose_list fs/inode.c:698 [inline]
 evict_inodes+0x5f8/0x690 fs/inode.c:748
 generic_shutdown_super+0x98/0x340 fs/super.c:479
 kill_anon_super+0x3b/0x60 fs/super.c:1107
 btrfs_kill_super+0x41/0x50 fs/btrfs/super.c:2138
 deactivate_locked_super+0xa4/0x110 fs/super.c:331
 cleanup_mnt+0x426/0x4c0 fs/namespace.c:1177
 task_work_run+0x24a/0x300 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0xd9/0x100 kernel/entry/common.c:171
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x64/0x280 kernel/entry/common.c:297
 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f3e6748d5d7
Code: ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 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:00007ffc8824b7c8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f3e6748d5d7
RDX: 00007ffc8824b89b RSI: 000000000000000a RDI: 00007ffc8824b890
RBP: 00007ffc8824b890 R08: 00000000ffffffff R09: 00007ffc8824b660
R10: 00005555568b4893 R11: 0000000000000246 R12: 00007f3e674e6cdc
R13: 00007ffc8824c950 R14: 00005555568b4810 R15: 00007ffc8824c990
 </TASK>

Allocated by task 17980:
 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:186 [inline]
 slab_post_alloc_hook+0x68/0x3a0 mm/slab.h:711
 slab_alloc_node mm/slub.c:3451 [inline]
 slab_alloc mm/slub.c:3459 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3466 [inline]
 kmem_cache_alloc+0x11f/0x2e0 mm/slub.c:3475
 kmem_cache_zalloc include/linux/slab.h:670 [inline]
 btrfs_get_or_create_delayed_node+0xbd/0x470 fs/btrfs/delayed-inode.c:129
 btrfs_delayed_update_inode+0x28/0x4b0 fs/btrfs/delayed-inode.c:1887
 btrfs_update_inode+0x16a/0x360 fs/btrfs/inode.c:4050
 btrfs_dirty_inode+0xdb/0x1a0 fs/btrfs/inode.c:5940
 inode_update_time fs/inode.c:1871 [inline]
 touch_atime+0x352/0x680 fs/inode.c:1944
 file_accessed include/linux/fs.h:2198 [inline]
 filemap_read+0xfcf/0x1170 mm/filemap.c:2759
 __kernel_read+0x422/0x8a0 fs/read_write.c:428
 integrity_kernel_read+0xb0/0xf0 security/integrity/iint.c:192
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
 ima_calc_file_hash+0x1643/0x1d20 security/integrity/ima/ima_crypto.c:573
 ima_collect_measurement+0x3a7/0x880 security/integrity/ima/ima_api.c:293
 process_measurement+0xfdb/0x1ce0 security/integrity/ima/ima_main.c:341
 ima_file_check+0xf1/0x170 security/integrity/ima/ima_main.c:539
 do_open fs/namei.c:3638 [inline]
 path_openat+0x280a/0x3170 fs/namei.c:3791
 do_filp_open+0x234/0x490 fs/namei.c:3818
 do_sys_openat2+0x13f/0x500 fs/open.c:1356
 do_sys_open fs/open.c:1372 [inline]
 __do_sys_openat fs/open.c:1388 [inline]
 __se_sys_openat fs/open.c:1383 [inline]
 __x64_sys_openat+0x247/0x290 fs/open.c:1383
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 18046:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:162 [inline]
 slab_free_hook mm/slub.c:1781 [inline]
 slab_free_freelist_hook mm/slub.c:1807 [inline]
 slab_free mm/slub.c:3786 [inline]
 kmem_cache_free+0x297/0x520 mm/slub.c:3808
 btrfs_evict_inode+0x72e/0x1010 fs/btrfs/inode.c:5336
 evict+0x2a4/0x620 fs/inode.c:665
 __btrfs_run_defrag_inode fs/btrfs/defrag.c:282 [inline]
 btrfs_run_defrag_inodes+0xa90/0xe20 fs/btrfs/defrag.c:328
 cleaner_kthread+0x287/0x3c0 fs/btrfs/disk-io.c:1733
 kthread+0x2b8/0x350 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

The buggy address belongs to the object at ffff88802bf9fb20
 which belongs to the cache btrfs_delayed_node of size 432
The buggy address is located 88 bytes inside of
 freed 432-byte region [ffff88802bf9fb20, ffff88802bf9fcd0)

The buggy address belongs to the physical page:
page:ffffea0000afe780 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802bf9e7c0 pfn:0x2bf9e
head:ffffea0000afe780 order:1 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff88814afef280 dead000000000122 0000000000000000
raw: ffff88802bf9e7c0 0000000080100009 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5157, tgid 5155 (syz-executor.0), ts 205681986516, free_ts 205477039506
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1731
 prep_new_page mm/page_alloc.c:1738 [inline]
 get_page_from_freelist+0x321c/0x33a0 mm/page_alloc.c:3502
 __alloc_pages+0x255/0x670 mm/page_alloc.c:4768
 alloc_slab_page+0x6a/0x160 mm/slub.c:1851
 allocate_slab mm/slub.c:1998 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2051
 ___slab_alloc+0xa85/0x10a0 mm/slub.c:3192
 __slab_alloc mm/slub.c:3291 [inline]
 __slab_alloc_node mm/slub.c:3344 [inline]
 slab_alloc_node mm/slub.c:3441 [inline]
 slab_alloc mm/slub.c:3459 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3466 [inline]
 kmem_cache_alloc+0x1b9/0x2e0 mm/slub.c:3475
 kmem_cache_zalloc include/linux/slab.h:670 [inline]
 btrfs_get_or_create_delayed_node+0xbd/0x470 fs/btrfs/delayed-inode.c:129
 btrfs_insert_delayed_dir_index+0xa3/0xca0 fs/btrfs/delayed-inode.c:1432
 btrfs_insert_dir_item+0x47d/0x630 fs/btrfs/dir-item.c:166
 btrfs_add_link+0x287/0xc60 fs/btrfs/inode.c:6425
 btrfs_create_new_inode+0x1a57/0x27f0 fs/btrfs/inode.c:6366
 btrfs_create_common+0x1f9/0x300 fs/btrfs/inode.c:6501
 lookup_open fs/namei.c:3492 [inline]
 open_last_lookups fs/namei.c:3560 [inline]
 path_openat+0x13df/0x3170 fs/namei.c:3788
 do_filp_open+0x234/0x490 fs/namei.c:3818
 do_sys_openat2+0x13f/0x500 fs/open.c:1356
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+0x903/0xa30 mm/page_alloc.c:2564
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2659
 qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x14b/0x160 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook+0x68/0x3a0 mm/slab.h:711
 slab_alloc_node mm/slub.c:3451 [inline]
 slab_alloc mm/slub.c:3459 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3466 [inline]
 kmem_cache_alloc+0x11f/0x2e0 mm/slub.c:3475
 getname_flags+0xbc/0x4e0 fs/namei.c:140
 user_path_at_empty+0x2e/0x180 fs/namei.c:2906
 do_readlinkat+0x118/0x3b0 fs/stat.c:477
 __do_sys_readlink fs/stat.c:510 [inline]
 __se_sys_readlink fs/stat.c:507 [inline]
 __x64_sys_readlink+0x7f/0x90 fs/stat.c:507
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff88802bf9fa00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802bf9fa80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88802bf9fb00: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff88802bf9fb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802bf9fc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/31 05:39 upstream afead42fdfca 09898419 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in __btrfs_release_delayed_node
2023/05/06 03:48 upstream 7163a2111f6c de870ca5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in __btrfs_release_delayed_node
* Struck through repros no longer work on HEAD.