syzbot


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

Status: auto-obsoleted due to no activity on 2024/04/13 00:17
Subsystems: block
[Documentation on labels]
Reported-by: syzbot+db265923e3d158c61f80@syzkaller.appspotmail.com
First crash: 299d, last: 299d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in bdev_release+0x986/0xa80 block/bdev.c:956
Read of size 8 at addr ffff88807f389880 by task syz-executor.4/15389

CPU: 1 PID: 15389 Comm: syz-executor.4 Not tainted 6.7.0-syzkaller-09928-g052d534373b7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:488
 kasan_report+0xda/0x110 mm/kasan/report.c:601
 bdev_release+0x986/0xa80 block/bdev.c:956
 __btrfs_free_extra_devids+0x123/0x7a0 fs/btrfs/volumes.c:1019
 btrfs_free_extra_devids+0x87/0x180 fs/btrfs/volumes.c:1046
 open_ctree+0x1ebd/0x5430 fs/btrfs/disk-io.c:3388
 btrfs_fill_super fs/btrfs/super.c:940 [inline]
 btrfs_get_tree_super fs/btrfs/super.c:1852 [inline]
 btrfs_get_tree+0x11e5/0x1b90 fs/btrfs/super.c:2078
 vfs_get_tree+0x8c/0x370 fs/super.c:1784
 fc_mount+0x16/0xc0 fs/namespace.c:1125
 btrfs_get_tree_subvol fs/btrfs/super.c:2041 [inline]
 btrfs_get_tree+0xa4f/0x1b90 fs/btrfs/super.c:2079
 vfs_get_tree+0x8c/0x370 fs/super.c:1784
 do_new_mount fs/namespace.c:3352 [inline]
 path_mount+0x14e6/0x1f20 fs/namespace.c:3679
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount fs/namespace.c:3875 [inline]
 __x64_sys_mount+0x293/0x310 fs/namespace.c:3875
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7fd62c67e4aa
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007fd62d3b8ef8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fd62d3b8f80 RCX: 00007fd62c67e4aa
RDX: 00000000200051c0 RSI: 0000000020005200 RDI: 00007fd62d3b8f40
RBP: 00000000200051c0 R08: 00007fd62d3b8f80 R09: 0000000001000008
R10: 0000000001000008 R11: 0000000000000202 R12: 0000000020005200
R13: 00007fd62d3b8f40 R14: 00000000000051ab R15: 0000000020000280
 </TASK>

Allocated by task 15227:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:372 [inline]
 __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:389
 kmalloc include/linux/slab.h:590 [inline]
 kzalloc include/linux/slab.h:711 [inline]
 ref_tracker_alloc+0x17c/0x5a0 lib/ref_tracker.c:203
 __netdev_tracker_alloc include/linux/netdevice.h:4147 [inline]
 netdev_hold include/linux/netdevice.h:4176 [inline]
 netdev_hold include/linux/netdevice.h:4171 [inline]
 inetdev_init+0x245/0x580 net/ipv4/devinet.c:282
 inetdev_event+0x1191/0x19a0 net/ipv4/devinet.c:1555
 notifier_call_chain+0xb6/0x3b0 kernel/notifier.c:93
 call_netdevice_notifiers_info+0xbe/0x130 net/core/dev.c:1966
 call_netdevice_notifiers_extack net/core/dev.c:2004 [inline]
 call_netdevice_notifiers net/core/dev.c:2018 [inline]
 register_netdevice+0x16e2/0x1da0 net/core/dev.c:10294
 br_add_bridge+0x9a/0xe0 net/bridge/br_if.c:469
 br_ioctl_stub+0x6af/0x8b0 net/bridge/br_ioctl.c:426
 br_ioctl_call+0x62/0xb0 net/socket.c:1195
 sock_ioctl+0x36d/0x6b0 net/socket.c:1295
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:871 [inline]
 __se_sys_ioctl fs/ioctl.c:857 [inline]
 __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Freed by task 15235:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3f/0x60 mm/kasan/generic.c:634
 poison_slab_object mm/kasan/common.c:241 [inline]
 __kasan_slab_free+0x121/0x1b0 mm/kasan/common.c:257
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2121 [inline]
 slab_free mm/slub.c:4299 [inline]
 kfree+0x124/0x360 mm/slub.c:4409
 ref_tracker_dir_exit+0x1eb/0x680 lib/ref_tracker.c:167
 free_netdev+0x2fa/0x5f0 net/core/dev.c:10956
 netdev_run_todo+0xd2b/0x12e0 net/core/dev.c:10575
 br_ioctl_stub+0x247/0x8b0 net/bridge/br_ioctl.c:437
 br_ioctl_call+0x62/0xb0 net/socket.c:1195
 sock_ioctl+0x36d/0x6b0 net/socket.c:1295
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:871 [inline]
 __se_sys_ioctl fs/ioctl.c:857 [inline]
 __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

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

The buggy address belongs to the physical page:
page:ffffea0001fce240 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7f389
ksm flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000800 ffff888013041500 ffffea0000b4f540 dead000000000003
raw: 0000000000000000 0000000000200020 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 5098, tgid 5098 (udevd), ts 2245821417374, free_ts 2245359350720
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2d0/0x350 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311
 __alloc_pages+0x22f/0x2440 mm/page_alloc.c:4567
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page mm/slub.c:2190 [inline]
 allocate_slab mm/slub.c:2354 [inline]
 new_slab+0xcc/0x3a0 mm/slub.c:2407
 ___slab_alloc+0x4af/0x19a0 mm/slub.c:3540
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3625
 __slab_alloc_node mm/slub.c:3678 [inline]
 slab_alloc_node mm/slub.c:3850 [inline]
 __do_kmalloc_node mm/slub.c:3980 [inline]
 __kmalloc+0x3b4/0x440 mm/slub.c:3994
 kmalloc include/linux/slab.h:594 [inline]
 kzalloc include/linux/slab.h:711 [inline]
 tomoyo_encode2+0x100/0x3d0 security/tomoyo/realpath.c:45
 tomoyo_encode+0x29/0x50 security/tomoyo/realpath.c:80
 tomoyo_realpath_from_path+0x196/0x710 security/tomoyo/realpath.c:283
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x26f/0x450 security/tomoyo/file.c:822
 security_inode_getattr+0xf1/0x150 security/security.c:2237
 vfs_getattr+0x36/0xa0 fs/stat.c:173
 vfs_statx+0x171/0x550 fs/stat.c:248
 vfs_fstatat+0xb3/0x140 fs/stat.c:304
 __do_sys_newfstatat+0x98/0x110 fs/stat.c:468
page last free pid 5619 tgid 5619 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x51f/0xb10 mm/page_alloc.c:2346
 free_unref_page_list+0xe6/0xb40 mm/page_alloc.c:2532
 release_pages+0x32a/0x14f0 mm/swap.c:1042
 __folio_batch_release+0x77/0xe0 mm/swap.c:1062
 folio_batch_release include/linux/pagevec.h:83 [inline]
 truncate_inode_pages_range+0x33e/0xf00 mm/truncate.c:362
 kill_bdev block/bdev.c:79 [inline]
 blkdev_flush_mapping+0x144/0x310 block/bdev.c:638
 blkdev_put_whole+0xb9/0xe0 block/bdev.c:669
 bdev_release+0x509/0xa80 block/bdev.c:985
 blkdev_release+0x37/0x50 block/fops.c:631
 __fput+0x270/0xb70 fs/file_table.c:376
 __fput_sync+0x47/0x50 fs/file_table.c:461
 __do_sys_close fs/open.c:1554 [inline]
 __se_sys_close fs/open.c:1539 [inline]
 __x64_sys_close+0x87/0xf0 fs/open.c:1539
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Memory state around the buggy address:
 ffff88807f389780: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807f389800: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807f389880: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff88807f389900: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807f389980: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/01/14 00:16 upstream 052d534373b7 551587c1 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in bdev_release
* Struck through repros no longer work on HEAD.