syzbot


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

Status: auto-obsoleted due to no activity on 2024/10/25 04:03
Subsystems: bpf net
[Documentation on labels]
Reported-by: syzbot+fc994a2123cc567594d5@syzkaller.appspotmail.com
First crash: 117d, last: 100d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in cpu_map_enqueue 9 13d 100d 0/3 upstream: reported on 2024/07/27 15:55
android-6-1 KASAN: use-after-free Read in cpu_map_enqueue origin:lts syz 35 6h30m 110d 0/2 premoderation: reported syz repro on 2024/07/17 04:10

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in bq_enqueue kernel/bpf/cpumap.c:710 [inline]
BUG: KASAN: slab-use-after-free in cpu_map_enqueue+0x33b/0x3b0 kernel/bpf/cpumap.c:736
Read of size 8 at addr ffff8880481a1208 by task syz.2.3543/14414

CPU: 2 PID: 14414 Comm: syz.2.3543 Not tainted 6.10.0-rc7-syzkaller-00076-g9d9a2f29aefd #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:488
 kasan_report+0xd9/0x110 mm/kasan/report.c:601
 bq_enqueue kernel/bpf/cpumap.c:710 [inline]
 cpu_map_enqueue+0x33b/0x3b0 kernel/bpf/cpumap.c:736
 __xdp_do_redirect_frame net/core/filter.c:4406 [inline]
 xdp_do_redirect+0x72e/0xb10 net/core/filter.c:4442
 tun_xdp_act+0xd3/0xc30 drivers/net/tun.c:1626
 tun_build_skb.constprop.0+0xd7c/0x1250 drivers/net/tun.c:1716
 tun_get_user+0x888/0x3c30 drivers/net/tun.c:1819
 tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048
 new_sync_write fs/read_write.c:497 [inline]
 vfs_write+0x6b6/0x1140 fs/read_write.c:590
 ksys_write+0x12f/0x260 fs/read_write.c:643
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f127f57475f
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 29 8c 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 7c 8c 02 00 48
RSP: 002b:00007f12803a3010 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f127f703f60 RCX: 00007f127f57475f
RDX: 000000000000000e RSI: 0000000020001540 RDI: 00000000000000c8
RBP: 00007f127f5e4e60 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000000e R11: 0000000000000293 R12: 0000000000000000
R13: 000000000000000b R14: 00007f127f703f60 R15: 00007fff84e65848
 </TASK>

Allocated by task 13957:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387
 kmalloc_noprof include/linux/slab.h:660 [inline]
 kmalloc_array_noprof include/linux/slab.h:698 [inline]
 kvm_arch_vcpu_create+0x36a/0xaa0 arch/x86/kvm/x86.c:12175
 kvm_vm_ioctl_create_vcpu arch/x86/kvm/../../../virt/kvm/kvm_main.c:4245 [inline]
 kvm_vm_ioctl+0xf77/0x3de0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:5087
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl fs/ioctl.c:893 [inline]
 __x64_sys_ioctl+0x193/0x220 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 13956:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
 poison_slab_object+0xf7/0x160 mm/kasan/common.c:240
 __kasan_slab_free+0x32/0x50 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2196 [inline]
 slab_free mm/slub.c:4438 [inline]
 kfree+0x12a/0x3b0 mm/slub.c:4559
 kvm_arch_vcpu_destroy+0x108/0x2a0 arch/x86/kvm/x86.c:12278
 kvm_vcpu_destroy arch/x86/kvm/../../../virt/kvm/kvm_main.c:511 [inline]
 kvm_destroy_vcpus+0x114/0x2a0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:531
 kvm_arch_destroy_vm+0x2ec/0x490 arch/x86/kvm/x86.c:12778
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:1345 [inline]
 kvm_put_kvm+0x510/0xb80 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1381
 kvm_vm_release+0x42/0x60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1404
 __fput+0x408/0xbb0 fs/file_table.c:422
 task_work_run+0x14e/0x250 kernel/task_work.c:180
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x275/0x2a0 kernel/entry/common.c:218
 do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8880481a1200
 which belongs to the cache kmalloc-cg-256 of size 256
The buggy address is located 8 bytes inside of
 freed 256-byte region [ffff8880481a1200, ffff8880481a1300)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880481a0000 pfn:0x481a0
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff88802ba7b501
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffefff(slab)
raw: 00fff00000000040 ffff88801544dcc0 dead000000000122 0000000000000000
raw: ffff8880481a0000 000000008010000f 00000001ffffefff ffff88802ba7b501
head: 00fff00000000040 ffff88801544dcc0 dead000000000122 0000000000000000
head: ffff8880481a0000 000000008010000f 00000001ffffefff ffff88802ba7b501
head: 00fff00000000001 ffffea0001206801 ffffffffffffffff 0000000000000000
head: 0000000000000002 0000000000000000 00000000ffffffff 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 9264, tgid 9259 (syz.3.1554), ts 187687736540, free_ts 187646811035
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1473
 prep_new_page mm/page_alloc.c:1481 [inline]
 get_page_from_freelist+0x1353/0x2e50 mm/page_alloc.c:3425
 __alloc_pages_noprof+0x22b/0x2460 mm/page_alloc.c:4683
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x56/0x110 mm/slub.c:2265
 allocate_slab mm/slub.c:2428 [inline]
 new_slab+0x84/0x260 mm/slub.c:2481
 ___slab_alloc+0xdac/0x1870 mm/slub.c:3667
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3757
 __slab_alloc_node mm/slub.c:3810 [inline]
 slab_alloc_node mm/slub.c:3990 [inline]
 kmalloc_trace_noprof+0x2b4/0x300 mm/slub.c:4149
 kmalloc_noprof include/linux/slab.h:660 [inline]
 kzalloc_noprof include/linux/slab.h:778 [inline]
 fuse_file_alloc+0x51/0x2d0 fs/fuse/file.c:58
 fuse_file_open+0x197/0x780 fs/fuse/file.c:134
 fuse_do_open fs/fuse/file.c:175 [inline]
 fuse_open+0x1e8/0x920 fs/fuse/file.c:264
 do_dentry_open+0x91f/0x15f0 fs/open.c:955
 vfs_open+0x82/0x3f0 fs/open.c:1086
 do_open fs/namei.c:3654 [inline]
 path_openat+0x21fc/0x2e50 fs/namei.c:3813
 do_filp_open+0x1dc/0x430 fs/namei.c:3840
 do_sys_openat2+0x17a/0x1e0 fs/open.c:1413
page last free pid 4690 tgid 4690 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1093 [inline]
 free_unref_page+0x64a/0xe40 mm/page_alloc.c:2588
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x4e/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3940 [inline]
 slab_alloc_node mm/slub.c:4002 [inline]
 __do_kmalloc_node mm/slub.c:4122 [inline]
 __kmalloc_noprof+0x19d/0x410 mm/slub.c:4136
 kmalloc_noprof include/linux/slab.h:664 [inline]
 tomoyo_realpath_from_path+0xb9/0x720 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x273/0x450 security/tomoyo/file.c:822
 security_inode_getattr+0xf4/0x160 security/security.c:2269
 vfs_getattr fs/stat.c:173 [inline]
 vfs_fstat+0x53/0xd0 fs/stat.c:198
 vfs_fstatat+0x134/0x150 fs/stat.c:300
 __do_sys_newfstatat+0xa6/0x130 fs/stat.c:468
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff8880481a1100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880481a1180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880481a1200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8880481a1280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880481a1300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/11 16:16 upstream 9d9a2f29aefd 3cf1187a .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in cpu_map_enqueue
2024/07/10 10:58 bpf f153831097b4 e7213be3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce KASAN: slab-use-after-free Read in cpu_map_enqueue
2024/07/27 04:02 git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git fixes c562ba719df5 46eb10b7 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-riscv64 KASAN: slab-use-after-free Read in cpu_map_enqueue
* Struck through repros no longer work on HEAD.