syzbot


KASAN: use-after-free Read in bdev_try_to_free_page

Status: premoderation: reported on 2024/11/29 04:24
Reported-by: syzbot+4c9cbc28f9fc23a5ad62@syzkaller.appspotmail.com
First crash: 23d, last: 23d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in bdev_try_to_free_page+0x5e/0x140 fs/ext4/super.c:1461
Read of size 8 at addr ffff888105d93248 by task syz.2.739/3479

CPU: 0 PID: 3479 Comm: syz.2.739 Not tainted 5.10.226-syzkaller-00184-g139a6bb26d9d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 bdev_try_to_free_page+0x5e/0x140 fs/ext4/super.c:1461
 blkdev_releasepage+0xd9/0x100 fs/block_dev.c:1971
 try_to_release_page+0x188/0x1e0 mm/filemap.c:3705
 shrink_page_list+0x1a25/0x4c60 mm/vmscan.c:1460
 shrink_inactive_list+0x591/0x1150 mm/vmscan.c:2068
 shrink_list mm/vmscan.c:2287 [inline]
 shrink_lruvec+0xced/0x3860 mm/vmscan.c:5466
 shrink_node_memcgs mm/vmscan.c:5653 [inline]
 shrink_node+0xded/0x2000 mm/vmscan.c:5683
 shrink_zones mm/vmscan.c:5889 [inline]
 do_try_to_free_pages+0x652/0x1630 mm/vmscan.c:5947
 try_to_free_mem_cgroup_pages+0x369/0x830 mm/vmscan.c:6265
 try_charge+0x4b8/0x15f0 mm/memcontrol.c:2742
 __mem_cgroup_charge+0x147/0x6e0 mm/memcontrol.c:6868
 mem_cgroup_charge include/linux/memcontrol.h:458 [inline]
 __add_to_page_cache_locked+0x29d/0xba0 mm/filemap.c:854
 add_to_page_cache_lru+0x117/0x2c0 mm/filemap.c:948
 pagecache_get_page+0x71e/0x950 mm/filemap.c:1859
 filemap_fault+0x1fd8/0x2660 mm/filemap.c:2813
 ext4_filemap_fault+0x89/0xa0 fs/ext4/inode.c:6357
 __do_fault mm/memory.c:4036 [inline]
 do_read_fault mm/memory.c:4371 [inline]
 do_fault mm/memory.c:4499 [inline]
 handle_pte_fault+0x237f/0x3e10 mm/memory.c:4763
 __handle_mm_fault mm/memory.c:4916 [inline]
 handle_mm_fault+0x11d6/0x1a10 mm/memory.c:5330
 faultin_page mm/gup.c:902 [inline]
 __get_user_pages+0xb31/0x11b0 mm/gup.c:1121
 __get_user_pages_locked mm/gup.c:1307 [inline]
 get_dump_page+0x19d/0x7a0 mm/gup.c:1586
 dump_user_range+0x43/0x1a0 fs/coredump.c:898
 elf_core_dump+0x33bd/0x3c10 fs/binfmt_elf.c:2290
 do_coredump+0x1eb8/0x2d60 fs/coredump.c:811
 get_signal+0x102c/0x1410 kernel/signal.c:2776
 arch_do_signal_or_restart+0xbd/0x17c0 arch/x86/kernel/signal.c:805
 handle_signal_work kernel/entry/common.c:145 [inline]
 exit_to_user_mode_loop+0x9b/0xd0 kernel/entry/common.c:169
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 irqentry_exit_to_user_mode+0x4e/0x80 kernel/entry/common.c:287
 irqentry_exit+0x12/0x60 kernel/entry/common.c:375
 exc_page_fault+0x33d/0x5b0 arch/x86/mm/fault.c:1487
 asm_exc_page_fault+0x1e/0x30 arch/x86/include/asm/idtentry.h:571
RIP: 0033:0x0
Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
RSP: 002b:0000000020000138 EFLAGS: 00010217
RAX: 0000000000000000 RBX: 00007f7969707fa0 RCX: 00007f7969542809
RDX: 0000000020000140 RSI: 0000000020000130 RDI: 0000000000840000
RBP: 00007f79695b593e R08: 0000000020000600 R09: 0000000020000600
R10: 0000000020000180 R11: 0000000000000206 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7969707fa0 R15: 00007ffed2e4a6b8

Allocated by task 3790:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:430 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518
 kasan_kmalloc include/linux/kasan.h:254 [inline]
 kmem_cache_alloc_trace+0x18a/0x2e0 mm/slub.c:2974
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 ext4_fill_super+0xef/0x9150 fs/ext4/super.c:4018
 mount_bdev+0x262/0x370 fs/super.c:1442
 ext4_mount+0x34/0x40 fs/ext4/super.c:6638
 legacy_get_tree+0xf1/0x190 fs/fs_context.c:593
 vfs_get_tree+0x88/0x290 fs/super.c:1572
 do_new_mount+0x2ba/0xb30 fs/namespace.c:2917
 path_mount+0x56f/0xcb0 fs/namespace.c:3247
 do_mount fs/namespace.c:3260 [inline]
 __do_sys_mount fs/namespace.c:3468 [inline]
 __se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3445
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3445
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 289:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kfree+0xc3/0x270 mm/slub.c:4191
 ext4_put_super+0x928/0xc70 fs/ext4/super.c:1267
 generic_shutdown_super+0x147/0x320 fs/super.c:465
 kill_block_super+0x7e/0xe0 fs/super.c:1469
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:189
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xbf/0xd0 kernel/entry/common.c:172
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xa2/0x1a0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2976 [inline]
 call_rcu+0x135/0x11f0 kernel/rcu/tree.c:3050
 netlink_release+0x12df/0x16f0 net/netlink/af_netlink.c:811
 __sock_release net/socket.c:597 [inline]
 sock_close+0xdf/0x270 net/socket.c:1286
 __fput+0x33d/0x7b0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x129/0x190 kernel/task_work.c:189
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863
 do_group_exit+0x141/0x310 kernel/exit.c:985
 get_signal+0x10a0/0x1410 kernel/signal.c:2790
 arch_do_signal_or_restart+0xbd/0x17c0 arch/x86/kernel/signal.c:805
 handle_signal_work kernel/entry/common.c:145 [inline]
 exit_to_user_mode_loop+0x9b/0xd0 kernel/entry/common.c:169
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xa2/0x1a0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2976 [inline]
 call_rcu+0x135/0x11f0 kernel/rcu/tree.c:3050
 netlink_release+0x12df/0x16f0 net/netlink/af_netlink.c:811
 __sock_release net/socket.c:597 [inline]
 sock_release+0x7e/0x140 net/socket.c:625
 netlink_kernel_release+0x4d/0x60 net/netlink/af_netlink.c:2104
 genl_pernet_exit+0x40/0x60 net/netlink/genetlink.c:1388
 ops_exit_list net/core/net_namespace.c:185 [inline]
 cleanup_net+0x66c/0xcb0 net/core/net_namespace.c:609
 process_one_work+0x6dc/0xbd0 kernel/workqueue.c:2301
 worker_thread+0xaea/0x1510 kernel/workqueue.c:2447
 kthread+0x34b/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff888105d93000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 584 bytes inside of
 2048-byte region [ffff888105d93000, ffff888105d93800)
The buggy address belongs to the page:
page:ffffea0004176400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105d90
head:ffffea0004176400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 dead000000000100 dead000000000122 ffff888100042d80
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 2332216639, free_ts 0
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5348
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x80/0x400 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x302/0x4b0 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc_trace+0x1bd/0x2e0 mm/slub.c:2972
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 acpi_os_allocate_zeroed include/acpi/platform/aclinuxex.h:57 [inline]
 acpi_ds_create_walk_state+0xff/0x2a0 drivers/acpi/acpica/dswstate.c:518
 acpi_ds_call_control_method+0x132/0x7b0 drivers/acpi/acpica/dsmethod.c:498
 acpi_ps_parse_aml+0x2f7/0x9a0 drivers/acpi/acpica/psparse.c:503
 acpi_ps_execute_method+0x71d/0x850 drivers/acpi/acpica/psxface.c:190
 acpi_ns_evaluate+0x606/0x9d0 drivers/acpi/acpica/nseval.c:205
 acpi_evaluate_object+0x597/0xaf0 drivers/acpi/acpica/nsxfeval.c:354
 acpi_evaluate_integer+0x112/0x230 drivers/acpi/utils.c:279
 acpi_bus_get_status_handle+0x26/0x80 drivers/acpi/bus.c:83
 acpi_bus_type_and_status drivers/acpi/scan.c:1757 [inline]
 acpi_bus_check_add+0x34d/0xe50 drivers/acpi/scan.c:1911
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888105d93100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888105d93180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888105d93200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff888105d93280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888105d93300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/29 04:23 android13-5.10-lts 139a6bb26d9d 5df23865 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in bdev_try_to_free_page
* Struck through repros no longer work on HEAD.