==================================================================
BUG: KASAN: use-after-free in bq_enqueue kernel/bpf/cpumap.c:749 [inline]
BUG: KASAN: use-after-free in cpu_map_enqueue+0xb4/0x370 kernel/bpf/cpumap.c:775
Read of size 8 at addr ffff888111537308 by task syz.3.3086/9877
CPU: 0 PID: 9877 Comm: syz.3.3086 Not tainted 6.1.93-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x158/0x4e0 mm/kasan/report.c:395
kasan_report+0x13c/0x170 mm/kasan/report.c:495
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351
bq_enqueue kernel/bpf/cpumap.c:749 [inline]
cpu_map_enqueue+0xb4/0x370 kernel/bpf/cpumap.c:775
__xdp_do_redirect_frame net/core/filter.c:4283 [inline]
xdp_do_redirect+0x5b0/0xc60 net/core/filter.c:4327
tun_xdp_act+0xdb/0xc00 drivers/net/tun.c:1625
tun_build_skb drivers/net/tun.c:1715 [inline]
tun_get_user+0xb35/0x3a90 drivers/net/tun.c:1818
tun_chr_write_iter+0x129/0x210 drivers/net/tun.c:2044
call_write_iter include/linux/fs.h:2265 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x893/0xe30 fs/read_write.c:584
ksys_write+0x199/0x2c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:646
x64_sys_call+0x2f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:2
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:0x7fc800b7c9df
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 c9 8d 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 1c 8e 02 00 48
RSP: 002b:00007fc80196a000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fc800d35f80 RCX: 00007fc800b7c9df
RDX: 0000000000000066 RSI: 0000000020000900 RDI: 00000000000000c8
RBP: 00007fc800bf0b76 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000066 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fc800d35f80 R15: 00007ffcd1358f28
Allocated by task 9857:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
__do_kmalloc_node mm/slab_common.c:955 [inline]
__kmalloc_node+0xb4/0x1e0 mm/slab_common.c:962
kmalloc_node include/linux/slab.h:582 [inline]
bpf_map_kmalloc_node+0xd0/0x2c0 kernel/bpf/syscall.c:452
__cpu_map_entry_alloc kernel/bpf/cpumap.c:445 [inline]
cpu_map_update_elem+0x28f/0xf50 kernel/bpf/cpumap.c:603
bpf_map_update_value+0x1a3/0x410 kernel/bpf/syscall.c:188
map_update_elem+0x500/0x680 kernel/bpf/syscall.c:1448
__sys_bpf+0x340/0x6d0 kernel/bpf/syscall.c:4993
__do_sys_bpf kernel/bpf/syscall.c:5109 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5107 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5107
x64_sys_call+0x87f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:322
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
Freed by task 9859:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
____kasan_slab_free+0x131/0x180 mm/kasan/common.c:236
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:244
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0x218/0x3b0 mm/slub.c:3674
kfree+0x7a/0xf0 mm/slab_common.c:1007
put_cpu_map_entry+0x6e2/0x760 kernel/bpf/cpumap.c:161
cpu_map_kthread_run+0x2460/0x2520 kernel/bpf/cpumap.c:408
kthread+0x26d/0x300 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
Last potentially related work creation:
kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
__kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
insert_work+0x56/0x310 kernel/workqueue.c:1361
__queue_work+0x9b6/0xd70 kernel/workqueue.c:1520
queue_work_on+0x105/0x170 kernel/workqueue.c:1548
queue_work include/linux/workqueue.h:512 [inline]
schedule_work include/linux/workqueue.h:573 [inline]
__cpu_map_entry_replace kernel/bpf/cpumap.c:558 [inline]
cpu_map_free+0x1e7/0x2c0 kernel/bpf/cpumap.c:641
bpf_map_free_deferred+0xf7/0x1b0 kernel/bpf/syscall.c:620
process_one_work+0x73d/0xcb0 kernel/workqueue.c:2292
worker_thread+0xa5d/0x1260 kernel/workqueue.c:2439
kthread+0x26d/0x300 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
Second to last potentially related work creation:
kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
__kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
call_rcu+0xec/0x1230 kernel/rcu/tree.c:2844
__cpu_map_entry_replace kernel/bpf/cpumap.c:556 [inline]
cpu_map_free+0x109/0x2c0 kernel/bpf/cpumap.c:641
bpf_map_free_deferred+0xf7/0x1b0 kernel/bpf/syscall.c:620
process_one_work+0x73d/0xcb0 kernel/workqueue.c:2292
worker_thread+0xa5d/0x1260 kernel/workqueue.c:2439
kthread+0x26d/0x300 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
The buggy address belongs to the object at ffff888111537300
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 8 bytes inside of
192-byte region [ffff888111537300, ffff8881115373c0)
The buggy address belongs to the physical page:
page:ffffea0004454dc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x111537
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 dead000000000100 dead000000000122 ffff888100041a00
raw: 0000000000000000 0000000000100010 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 188, tgid 188 (udevadm), ts 5284819548, free_ts 5284796491
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x1e2/0x1f0 mm/page_alloc.c:2513
prep_new_page mm/page_alloc.c:2520 [inline]
get_page_from_freelist+0x2df3/0x2ed0 mm/page_alloc.c:4279
__alloc_pages+0x3c2/0x7d0 mm/page_alloc.c:5547
allocate_slab mm/slub.c:1939 [inline]
new_slab+0xce/0x4c0 mm/slub.c:1992
___slab_alloc+0x6f9/0xb80 mm/slub.c:3180
__slab_alloc+0x5d/0xa0 mm/slub.c:3279
slab_alloc_node mm/slub.c:3364 [inline]
__kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3437
kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1045
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:692 [inline]
kernfs_fop_open+0x350/0xb00 fs/kernfs/file.c:666
do_dentry_open+0x88d/0x1150 fs/open.c:882
vfs_open+0x73/0x80 fs/open.c:1013
do_open fs/namei.c:3628 [inline]
path_openat+0x2532/0x2d60 fs/namei.c:3785
do_filp_open+0x230/0x480 fs/namei.c:3812
do_sys_openat2+0x13b/0x500 fs/open.c:1318
do_sys_open fs/open.c:1334 [inline]
__do_sys_openat fs/open.c:1350 [inline]
__se_sys_openat fs/open.c:1345 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1345
x64_sys_call+0x6bf/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:258
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1440 [inline]
free_pcp_prepare mm/page_alloc.c:1513 [inline]
free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3358
free_unref_page+0x36/0x3c0 mm/page_alloc.c:3453
free_the_page mm/page_alloc.c:750 [inline]
__free_pages+0x61/0xf0 mm/page_alloc.c:5636
free_pages+0x7c/0x90 mm/page_alloc.c:5647
selinux_genfs_get_sid+0x24d/0x2a0 security/selinux/hooks.c:1303
inode_doinit_with_dentry+0x8d2/0x1070 security/selinux/hooks.c:1498
selinux_d_instantiate+0x27/0x40 security/selinux/hooks.c:6390
security_d_instantiate+0x9f/0x100 security/security.c:2096
d_splice_alias+0x6d/0x390 fs/dcache.c:3147
kernfs_iop_lookup+0x29e/0x2f0 fs/kernfs/dir.c:1193
lookup_open fs/namei.c:3462 [inline]
open_last_lookups fs/namei.c:3552 [inline]
path_openat+0x10fd/0x2d60 fs/namei.c:3782
do_filp_open+0x230/0x480 fs/namei.c:3812
do_sys_openat2+0x13b/0x500 fs/open.c:1318
do_sys_open fs/open.c:1334 [inline]
__do_sys_openat fs/open.c:1350 [inline]
__se_sys_openat fs/open.c:1345 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1345
x64_sys_call+0x6bf/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:258
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
Memory state around the buggy address:
ffff888111537200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888111537280: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888111537300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888111537380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff888111537400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
general protection fault, probably for non-canonical address 0xe0892d3e9ee004db: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0x044989f4f70026d8-0x044989f4f70026df]
CPU: 0 PID: 9877 Comm: syz.3.3086 Tainted: G B 6.1.93-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
RIP: 0010:bq_enqueue kernel/bpf/cpumap.c:751 [inline]
RIP: 0010:cpu_map_enqueue+0x113/0x370 kernel/bpf/cpumap.c:775
Code: e8 03 42 80 3c 30 00 74 08 48 89 df e8 96 75 23 00 4c 8b 23 4f 8d 74 3c 58 4d 89 f5 49 c1 ed 03 48 b8 00 00 00 00 00 fc ff df <41> 0f b6 44 05 00 84 c0 0f 85 a8 01 00 00 4d 01 fc 41 8b 1e bf 08
RSP: 0018:ffffc900035a77a8 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: ffffffff862d4820 RCX: ffff88811e486480
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000008
RBP: ffffc900035a77e0 R08: ffffffff8195b7be R09: fffffbfff0de48f5
R10: 0000000000000000 R11: dffffc0000000001 R12: ffff8881f7000000
R13: 0089313e9ee004db R14: 044989f4f70026db R15: 044a017300002683
FS: 00007fc80196a6c0(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f058bb08178 CR3: 000000011f6b2000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__xdp_do_redirect_frame net/core/filter.c:4283 [inline]
xdp_do_redirect+0x5b0/0xc60 net/core/filter.c:4327
tun_xdp_act+0xdb/0xc00 drivers/net/tun.c:1625
tun_build_skb drivers/net/tun.c:1715 [inline]
tun_get_user+0xb35/0x3a90 drivers/net/tun.c:1818
tun_chr_write_iter+0x129/0x210 drivers/net/tun.c:2044
call_write_iter include/linux/fs.h:2265 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x893/0xe30 fs/read_write.c:584
ksys_write+0x199/0x2c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:646
x64_sys_call+0x2f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:2
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:0x7fc800b7c9df
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 c9 8d 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 1c 8e 02 00 48
RSP: 002b:00007fc80196a000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fc800d35f80 RCX: 00007fc800b7c9df
RDX: 0000000000000066 RSI: 0000000020000900 RDI: 00000000000000c8
RBP: 00007fc800bf0b76 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000066 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fc800d35f80 R15: 00007ffcd1358f28
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:bq_enqueue kernel/bpf/cpumap.c:751 [inline]
RIP: 0010:cpu_map_enqueue+0x113/0x370 kernel/bpf/cpumap.c:775
Code: e8 03 42 80 3c 30 00 74 08 48 89 df e8 96 75 23 00 4c 8b 23 4f 8d 74 3c 58 4d 89 f5 49 c1 ed 03 48 b8 00 00 00 00 00 fc ff df <41> 0f b6 44 05 00 84 c0 0f 85 a8 01 00 00 4d 01 fc 41 8b 1e bf 08
RSP: 0018:ffffc900035a77a8 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: ffffffff862d4820 RCX: ffff88811e486480
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000008
RBP: ffffc900035a77e0 R08: ffffffff8195b7be R09: fffffbfff0de48f5
R10: 0000000000000000 R11: dffffc0000000001 R12: ffff8881f7000000
R13: 0089313e9ee004db R14: 044989f4f70026db R15: 044a017300002683
FS: 00007fc80196a6c0(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f058bb08178 CR3: 000000011f6b2000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: e8 03 42 80 3c call 0x3c804208
5: 30 00 xor %al,(%rax)
7: 74 08 je 0x11
9: 48 89 df mov %rbx,%rdi
c: e8 96 75 23 00 call 0x2375a7
11: 4c 8b 23 mov (%rbx),%r12
14: 4f 8d 74 3c 58 lea 0x58(%r12,%r15,1),%r14
19: 4d 89 f5 mov %r14,%r13
1c: 49 c1 ed 03 shr $0x3,%r13
20: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
27: fc ff df
* 2a: 41 0f b6 44 05 00 movzbl 0x0(%r13,%rax,1),%eax <-- trapping instruction
30: 84 c0 test %al,%al
32: 0f 85 a8 01 00 00 jne 0x1e0
38: 4d 01 fc add %r15,%r12
3b: 41 8b 1e mov (%r14),%ebx
3e: bf .byte 0xbf
3f: 08 .byte 0x8