syzbot


KASAN: use-after-free Read in cpu_map_enqueue

Status: upstream: reported on 2024/07/27 15:55
Reported-by: syzbot+a2a53e07c86ee97916a1@syzkaller.appspotmail.com
First crash: 98d, last: 11d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-1 KASAN: use-after-free Read in cpu_map_enqueue origin:lts syz 26 9h09m 109d 0/2 premoderation: reported syz repro on 2024/07/17 04:10
upstream KASAN: slab-use-after-free Read in cpu_map_enqueue bpf net 3 99d 112d 0/28 auto-obsoleted due to no activity on 2024/10/25 04:03

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in bq_enqueue kernel/bpf/cpumap.c:749 [inline]
BUG: KASAN: use-after-free in cpu_map_enqueue+0xb6/0x370 kernel/bpf/cpumap.c:775
Read of size 8 at addr ffff88807c157c08 by task syz.1.2619/11359

CPU: 1 PID: 11359 Comm: syz.1.2619 Not tainted 6.1.114-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 bq_enqueue kernel/bpf/cpumap.c:749 [inline]
 cpu_map_enqueue+0xb6/0x370 kernel/bpf/cpumap.c:775
 __xdp_do_redirect_frame net/core/filter.c:4298 [inline]
 xdp_do_redirect_frame+0x2f0/0x660 net/core/filter.c:4356
 xdp_test_run_batch net/bpf/test_run.c:314 [inline]
 bpf_test_run_xdp_live+0xbf4/0x1ea0 net/bpf/test_run.c:362
 bpf_prog_test_run_xdp+0x7d1/0x1130 net/bpf/test_run.c:1393
 bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3685
 __sys_bpf+0x3eb/0x6c0 kernel/bpf/syscall.c:5038
 __do_sys_bpf kernel/bpf/syscall.c:5124 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5122 [inline]
 __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5122
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7fefcc97dff9
Code: ff ff c3 66 2e 0f 1f 84 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
RSP: 002b:00007fefcd74f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fefccb35f80 RCX: 00007fefcc97dff9
RDX: 0000000000000050 RSI: 00000000200000c0 RDI: 000000000000000a
RBP: 00007fefcc9f0296 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fefccb35f80 R15: 00007ffc6c6d35c8
 </TASK>

Allocated by task 10954:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:557 [inline]
 kmalloc_array include/linux/slab.h:608 [inline]
 kcalloc include/linux/slab.h:640 [inline]
 kvm_arch_vcpu_create+0x35b/0x920 arch/x86/kvm/x86.c:11973
 kvm_vm_ioctl_create_vcpu+0x30c/0x8e0 virt/kvm/kvm_main.c:3951
 kvm_vm_ioctl+0x60b/0xb60 virt/kvm/kvm_main.c:4723
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1548
 cpu_map_free+0xd7/0x1b0 kernel/bpf/cpumap.c:641
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2845
 __cpu_map_entry_replace+0x74/0x170 kernel/bpf/cpumap.c:556
 cpu_map_free+0xd7/0x1b0 kernel/bpf/cpumap.c:641
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

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

The buggy address belongs to the physical page:
page:ffffea0001f05580 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807c157200 pfn:0x7c156
head:ffffea0001f05580 order:1 compound_mapcount:0 compound_pincount:0
memcg:ffff888057d8eb01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888017c42c80
raw: ffff88807c157200 000000008010000e 00000001ffffffff ffff888057d8eb01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3640, tgid 3640 (syz-executor), ts 55007931600, free_ts 54940402518
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x322e/0x33b0 mm/page_alloc.c:4290
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5558
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc+0xa1/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 __register_sysctl_table+0xdc/0x11e0 fs/proc/proc_sysctl.c:1341
 ipv6_sysctl_net_init+0x39f/0x480 net/ipv6/sysctl_net_ipv6.c:288
 ops_init+0x35d/0x610 net/core/net_namespace.c:138
 setup_net+0x4b5/0xb90 net/core/net_namespace.c:335
 copy_net_ns+0x392/0x5d0 net/core/net_namespace.c:481
 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x531/0xa40 kernel/fork.c:3199
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464
 free_slab mm/slub.c:2031 [inline]
 discard_slab mm/slub.c:2037 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2586
 put_cpu_partial+0x17b/0x250 mm/slub.c:2662
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 __kmem_cache_alloc_node+0x137/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc+0xa1/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:562 [inline]
 tomoyo_add_entry security/tomoyo/common.c:2022 [inline]
 tomoyo_supervisor+0xeda/0x12d0 security/tomoyo/common.c:2094
 tomoyo_audit_path_number_log security/tomoyo/file.c:235 [inline]
 tomoyo_path_number_perm+0x58d/0x7f0 security/tomoyo/file.c:734
 security_file_ioctl+0x6d/0xa0 security/security.c:1568
 __do_sys_ioctl fs/ioctl.c:864 [inline]
 __se_sys_ioctl+0x47/0x160 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff88807c157b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807c157b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807c157c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88807c157c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807c157d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/22 16:40 linux-6.1.y 7ec6f9fa3d97 a93682b3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in cpu_map_enqueue
2024/10/14 20:58 linux-6.1.y aa4cd140bba5 b01b6661 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Read in cpu_map_enqueue
2024/10/10 02:06 linux-6.1.y aa4cd140bba5 0278d004 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Read in cpu_map_enqueue
2024/09/10 14:49 linux-6.1.y 5ca5b389fddf 86aa7bd7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Read in cpu_map_enqueue
2024/08/26 00:20 linux-6.1.y ee5e09825b81 d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Read in cpu_map_enqueue
2024/08/23 04:43 linux-6.1.y ee5e09825b81 ce8a9099 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Read in cpu_map_enqueue
2024/08/18 05:49 linux-6.1.y 117ac406ba90 dbc93b08 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Read in cpu_map_enqueue
2024/07/27 15:54 linux-6.1.y c1cec4dad96b 46eb10b7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in cpu_map_enqueue
2024/10/21 19:13 linux-6.1.y 54d90d17e8ce f1e4447c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf BUG: unable to handle kernel paging request in cpu_map_enqueue
* Struck through repros no longer work on HEAD.