syzbot


KASAN: use-after-free Read in unaccount_page_cache_page (2)

Status: premoderation: reported on 2024/08/23 02:36
Reported-by: syzbot+2660878ed6b4da17c8aa@syzkaller.appspotmail.com
First crash: 24d, last: 24d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Read in unaccount_page_cache_page 118 194d 669d 0/2 auto-obsoleted due to no activity on 2024/05/01 01:14
android-5-10 KASAN: use-after-free Read in unaccount_page_cache_page 150 148d 676d 0/2 auto-obsoleted due to no activity on 2024/06/10 16:28
android-54 KASAN: slab-out-of-bounds Read in unaccount_page_cache_page 2 229d 310d 0/2 auto-obsoleted due to no activity on 2024/04/30 10:15
android-5-10 KASAN: use-after-free Read in unaccount_page_cache_page (2) 1 33d 33d 0/2 premoderation: reported on 2024/08/13 21:29
android-54 KASAN: use-after-free Read in unaccount_page_cache_page 143 460d 674d 0/2 auto-obsoleted due to no activity on 2023/08/23 09:09

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in cleancache_fs_enabled_mapping include/linux/cleancache.h:56 [inline]
BUG: KASAN: use-after-free in cleancache_invalidate_page include/linux/cleancache.h:110 [inline]
BUG: KASAN: use-after-free in unaccount_page_cache_page+0x6d8/0x750 mm/filemap.c:167
Read of size 4 at addr ffff8881151b2470 by task syz.1.5664/18710

CPU: 0 PID: 18710 Comm: syz.1.5664 Tainted: G        W         5.15.156-syzkaller-00821-g29d153aabd54 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1c0 lib/dump_stack.c:106
 print_address_description+0x87/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:427 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:444
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
 cleancache_fs_enabled_mapping include/linux/cleancache.h:56 [inline]
 cleancache_invalidate_page include/linux/cleancache.h:110 [inline]
 unaccount_page_cache_page+0x6d8/0x750 mm/filemap.c:167
 __delete_from_page_cache+0xc6/0x5b0 mm/filemap.c:235
 __remove_mapping+0x566/0x690 mm/vmscan.c:1201
 shrink_page_list+0x2723/0x5c50 mm/vmscan.c:1798
 shrink_inactive_list mm/vmscan.c:2305 [inline]
 shrink_list mm/vmscan.c:2550 [inline]
 shrink_lruvec+0x17ec/0x4580 mm/vmscan.c:5753
 shrink_node_memcgs mm/vmscan.c:5945 [inline]
 shrink_node+0x1083/0x2550 mm/vmscan.c:5975
 shrink_zones mm/vmscan.c:6181 [inline]
 do_try_to_free_pages+0x5c6/0x1600 mm/vmscan.c:6239
 try_to_free_mem_cgroup_pages+0x36c/0x850 mm/vmscan.c:6553
 try_charge_memcg+0x48f/0x1550 mm/memcontrol.c:2686
 try_charge mm/memcontrol.c:2811 [inline]
 charge_memcg+0x6b/0x1a0 mm/memcontrol.c:6814
 __mem_cgroup_charge+0x37/0x130 mm/memcontrol.c:6850
 mem_cgroup_charge include/linux/memcontrol.h:715 [inline]
 shmem_add_to_page_cache+0x6cf/0xe90 mm/shmem.c:719
 shmem_getpage_gfp+0x1559/0x23c0 mm/shmem.c:1941
 shmem_getpage mm/shmem.c:152 [inline]
 shmem_write_begin+0xca/0x1b0 mm/shmem.c:2478
 generic_perform_write+0x2bc/0x5a0 mm/filemap.c:3849
 __generic_file_write_iter+0x25b/0x4b0 mm/filemap.c:3976
 generic_file_write_iter+0xaf/0x1c0 mm/filemap.c:4008
 __kernel_write+0x5ab/0xa60 fs/read_write.c:539
 __dump_emit+0x261/0x3a0 fs/coredump.c:875
 dump_emit+0x381/0x3f0 fs/coredump.c:912
 dump_user_range+0x86/0x1c0 fs/coredump.c:949
 elf_core_dump+0x3663/0x3e80 fs/binfmt_elf.c:2285
 do_coredump+0x1834/0x3050 fs/coredump.c:826
 get_signal+0x4c8/0x1630 kernel/signal.c:2882
 arch_do_signal_or_restart+0xbd/0x1680 arch/x86/kernel/signal.c:867
 handle_signal_work kernel/entry/common.c:154 [inline]
 exit_to_user_mode_loop+0xa0/0xe0 kernel/entry/common.c:178
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:214
 irqentry_exit_to_user_mode+0x9/0x10 kernel/entry/common.c:320
 irqentry_exit+0x12/0x40 kernel/entry/common.c:411
 exc_page_fault+0x47a/0x830 arch/x86/mm/fault.c:1599
 asm_exc_page_fault+0x27/0x30 arch/x86/include/asm/idtentry.h:568
RIP: 0033:0x7f134975ee81
Code: 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f
RSP: 002b:ffffffffffffff60 EFLAGS: 00010217
RAX: 0000000000000000 RBX: 00007f13498faf80 RCX: 00007f134975ee79
RDX: 0000000000000000 RSI: ffffffffffffff60 RDI: 0000000000000000
RBP: 00007f13497cc93e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f13498faf80 R15: 00007ffcbacd9ea8
 </TASK>

The buggy address belongs to the page:
page:ffffea0004546c80 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1151b2
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 0000000000000000 dead000000000000 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 5, migratetype Unmovable, gfp_mask 0x152cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 18564, ts 1039117469540, free_ts 1042080497345
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2605
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2611
 get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4485
 __alloc_pages+0x27e/0x8f0 mm/page_alloc.c:5779
 __alloc_pages_node include/linux/gfp.h:591 [inline]
 alloc_pages_node include/linux/gfp.h:605 [inline]
 alloc_pages include/linux/gfp.h:618 [inline]
 kmalloc_order+0x4a/0x160 mm/slab_common.c:975
 kmalloc_order_trace+0x1a/0xb0 mm/slab_common.c:994
 kmalloc_large include/linux/slab.h:532 [inline]
 __kmalloc+0x19c/0x270 mm/slub.c:4416
 __kmalloc_node include/linux/slab.h:469 [inline]
 kmalloc_node include/linux/slab.h:626 [inline]
 kvmalloc_node+0x1f0/0x4d0 mm/util.c:628
 kvmalloc include/linux/mm.h:851 [inline]
 wg_index_hashtable_alloc+0x1e/0x50 drivers/net/wireguard/peerlookup.c:85
 wg_newlink+0x159/0x740 drivers/net/wireguard/device.c:313
 __rtnl_newlink net/core/rtnetlink.c:3501 [inline]
 rtnl_newlink+0x1495/0x2050 net/core/rtnetlink.c:3549
 rtnetlink_rcv_msg+0x951/0xc40 net/core/rtnetlink.c:5629
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2505
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:5647
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x8df/0xac0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0xa0a/0xd20 net/netlink/af_netlink.c:1924
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1472 [inline]
 __free_pages_ok+0x985/0xa50 mm/page_alloc.c:1772
 free_the_page mm/page_alloc.c:807 [inline]
 __free_pages+0xe9/0xf0 mm/page_alloc.c:5855
 free_nonslab_page+0x82/0xc0 mm/slub.c:3555
 kfree+0x19e/0x220 mm/slub.c:4576
 kvfree+0x35/0x40 mm/util.c:664
 wg_destruct+0x29a/0x300 drivers/net/wireguard/device.c:249
 netdev_run_todo+0x7c0/0x9f0 net/core/dev.c:10657
 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:112
 default_device_exit_batch+0x38f/0x3f0 net/core/dev.c:11642
 ops_exit_list net/core/net_namespace.c:174 [inline]
 cleanup_net+0x6ce/0xc00 net/core/net_namespace.c:596
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

Memory state around the buggy address:
 ffff8881151b2300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8881151b2380: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff8881151b2400: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                             ^
 ffff8881151b2480: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8881151b2500: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
syz.1.5664 (18710) used greatest stack depth: 16048 bytes left

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/23 02:35 android13-5.15-lts 29d153aabd54 ce8a9099 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in unaccount_page_cache_page
* Struck through repros no longer work on HEAD.