==================================================================
BUG: KASAN: use-after-free in cpu_map_generic_redirect+0x1c7/0x780 kernel/bpf/cpumap.c:788
Read of size 8 at addr ffff88811ea28618 by task syz.0.1639/4500
CPU: 1 PID: 4500 Comm: syz.0.1639 Not tainted 6.1.90-syzkaller-00030-g370ea8bc2e0b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/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:316 [inline]
print_report+0x158/0x4e0 mm/kasan/report.c:427
kasan_report+0x13c/0x170 mm/kasan/report.c:531
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351
cpu_map_generic_redirect+0x1c7/0x780 kernel/bpf/cpumap.c:788
xdp_do_generic_redirect_map net/core/filter.c:4367 [inline]
xdp_do_generic_redirect+0x3b5/0xad0 net/core/filter.c:4412
do_xdp_generic+0x53e/0x800 net/core/dev.c:4954
tun_get_user+0x238a/0x3a90 drivers/net/tun.c:1920
tun_chr_write_iter+0x129/0x210 drivers/net/tun.c:2044
call_write_iter include/linux/fs.h:2274 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x902/0xeb0 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:0x7f3d75f7895f
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:00007f3d76e14000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f3d76115f80 RCX: 00007f3d75f7895f
RDX: 0000000000000d86 RSI: 0000000020001580 RDI: 00000000000000c8
RBP: 00007f3d75fe793e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000d86 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f3d76115f80 R15: 00007ffe48f950b8
Allocated by task 319:
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:379 [inline]
__kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388
kasan_kmalloc include/linux/kasan.h:212 [inline]
kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:692 [inline]
kernfs_fop_open+0x350/0xb10 fs/kernfs/file.c:666
do_dentry_open+0x891/0x1250 fs/open.c:884
vfs_open+0x73/0x80 fs/open.c:1015
do_open fs/namei.c:3627 [inline]
path_openat+0x2532/0x2d60 fs/namei.c:3784
do_filp_open+0x230/0x480 fs/namei.c:3811
do_sys_openat2+0x151/0x890 fs/open.c:1341
do_sys_open fs/open.c:1357 [inline]
__do_sys_openat fs/open.c:1373 [inline]
__se_sys_openat fs/open.c:1368 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1368
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
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+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:1368
__queue_work+0x9b6/0xd70 kernel/workqueue.c:1527
queue_work_on+0x105/0x170 kernel/workqueue.c:1555
queue_work include/linux/workqueue.h:510 [inline]
schedule_work include/linux/workqueue.h:571 [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:622
process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
kthread+0x26d/0x300 kernel/kthread.c:386
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_common kernel/rcu/tree.c:2806 [inline]
call_rcu+0xee/0x1340 kernel/rcu/tree.c:2925
__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:622
process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
kthread+0x26d/0x300 kernel/kthread.c:386
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
The buggy address belongs to the object at ffff88811ea28600
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 24 bytes inside of
192-byte region [ffff88811ea28600, ffff88811ea286c0)
The buggy address belongs to the physical page:
page:ffffea00047a8a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88811ea28100 pfn:0x11ea28
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea0004250048 ffffea0004355308 ffff888100042c00
raw: ffff88811ea28100 000000000010000b 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 281, tgid 281 (syz-executor), ts 19987622410, free_ts 19982104739
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
__alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714
alloc_slab_page+0x6c/0xf0
allocate_slab mm/slub.c:1962 [inline]
new_slab+0x90/0x3e0 mm/slub.c:2015
___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
__slab_alloc+0x5d/0xa0 mm/slub.c:3302
slab_alloc_node mm/slub.c:3387 [inline]
__kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3460
kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1047
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:692 [inline]
alloc_fs_context+0x65/0x830 fs/fs_context.c:257
fs_context_for_mount+0x24/0x30 fs/fs_context.c:304
do_new_mount+0x15c/0xb30 fs/namespace.c:3030
path_mount+0x671/0x1070 fs/namespace.c:3381
do_mount fs/namespace.c:3394 [inline]
__do_sys_mount fs/namespace.c:3602 [inline]
__se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3579
__x64_sys_mount+0xbf/0xd0 fs/namespace.c:3579
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1498 [inline]
free_pcp_prepare mm/page_alloc.c:1572 [inline]
free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3498
free_unref_page+0xb2/0x5c0 mm/page_alloc.c:3594
free_the_page mm/page_alloc.c:798 [inline]
__free_pages+0x61/0xf0 mm/page_alloc.c:5803
free_pages+0x7c/0x90 mm/page_alloc.c:5814
_pgd_free arch/x86/mm/pgtable.c:420 [inline]
pgd_free+0x17d/0x190 arch/x86/mm/pgtable.c:476
mm_free_pgd kernel/fork.c:833 [inline]
__mmdrop+0xb0/0x3e0 kernel/fork.c:884
mmdrop include/linux/sched/mm.h:50 [inline]
mmdrop_sched include/linux/sched/mm.h:78 [inline]
finish_task_switch+0x2cd/0x7b0 kernel/sched/core.c:5320
context_switch kernel/sched/core.c:5421 [inline]
__schedule+0xcaf/0x1550 kernel/sched/core.c:6744
schedule+0xc3/0x180 kernel/sched/core.c:6820
syslog_print+0x256/0x600 kernel/printk/printk.c:1528
do_syslog+0x732/0x7f0 kernel/printk/printk.c:1681
__do_sys_syslog kernel/printk/printk.c:1773 [inline]
__se_sys_syslog kernel/printk/printk.c:1771 [inline]
__x64_sys_syslog+0x7c/0x90 kernel/printk/printk.c:1771
x64_sys_call+0x2f9/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:104
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:
ffff88811ea28500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88811ea28580: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88811ea28600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88811ea28680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88811ea28700: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
BUG: kernel NULL pointer dereference, address: 0000000000000004
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 1260c9067 P4D 1260c9067 PUD 141544067 PMD 0
Oops: 0002 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 4500 Comm: syz.0.1639 Tainted: G B 6.1.90-syzkaller-00030-g370ea8bc2e0b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
RIP: 0010:atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:543 [inline]
RIP: 0010:queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
RIP: 0010:do_raw_spin_lock include/linux/spinlock.h:187 [inline]
RIP: 0010:__raw_spin_lock include/linux/spinlock_api_smp.h:134 [inline]
RIP: 0010:_raw_spin_lock+0xba/0x1b0 kernel/locking/spinlock.c:154
Code: 00 00 e8 59 5f 9d fc 4c 89 ff be 04 00 00 00 e8 4c 5f 9d fc 43 0f b6 04 26 84 c0 0f 85 a9 00 00 00 8b 44 24 20 b9 01 00 00 00 41 0f b1 4d 00 75 33 48 c7 04 24 0e 36 e0 45 49 c7 04 1c 00 00
RSP: 0018:ffffc90000e27680 EFLAGS: 00010297
RAX: 0000000000000000 RBX: 1ffff920001c4ed0 RCX: 0000000000000001
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffc90000e276a0
RBP: ffffc90000e27710 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: dffffc0000000000
R13: 0000000000000004 R14: 1ffff920001c4ed4 R15: ffffc90000e276a0
FS: 00007f3d76e146c0(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000004 CR3: 0000000128836000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
spin_lock include/linux/spinlock.h:351 [inline]
ptr_ring_produce include/linux/ptr_ring.h:128 [inline]
cpu_map_generic_redirect+0x1f4/0x780 kernel/bpf/cpumap.c:788
xdp_do_generic_redirect_map net/core/filter.c:4367 [inline]
xdp_do_generic_redirect+0x3b5/0xad0 net/core/filter.c:4412
do_xdp_generic+0x53e/0x800 net/core/dev.c:4954
tun_get_user+0x238a/0x3a90 drivers/net/tun.c:1920
tun_chr_write_iter+0x129/0x210 drivers/net/tun.c:2044
call_write_iter include/linux/fs.h:2274 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x902/0xeb0 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:0x7f3d75f7895f
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:00007f3d76e14000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f3d76115f80 RCX: 00007f3d75f7895f
RDX: 0000000000000d86 RSI: 0000000020001580 RDI: 00000000000000c8
RBP: 00007f3d75fe793e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000d86 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f3d76115f80 R15: 00007ffe48f950b8
Modules linked in:
CR2: 0000000000000004
---[ end trace 0000000000000000 ]---
RIP: 0010:atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:543 [inline]
RIP: 0010:queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
RIP: 0010:do_raw_spin_lock include/linux/spinlock.h:187 [inline]
RIP: 0010:__raw_spin_lock include/linux/spinlock_api_smp.h:134 [inline]
RIP: 0010:_raw_spin_lock+0xba/0x1b0 kernel/locking/spinlock.c:154
Code: 00 00 e8 59 5f 9d fc 4c 89 ff be 04 00 00 00 e8 4c 5f 9d fc 43 0f b6 04 26 84 c0 0f 85 a9 00 00 00 8b 44 24 20 b9 01 00 00 00 41 0f b1 4d 00 75 33 48 c7 04 24 0e 36 e0 45 49 c7 04 1c 00 00
RSP: 0018:ffffc90000e27680 EFLAGS: 00010297
RAX: 0000000000000000 RBX: 1ffff920001c4ed0 RCX: 0000000000000001
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffc90000e276a0
RBP: ffffc90000e27710 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: dffffc0000000000
R13: 0000000000000004 R14: 1ffff920001c4ed4 R15: ffffc90000e276a0
FS: 00007f3d76e146c0(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000004 CR3: 0000000128836000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 00 00 add %al,(%rax)
2: e8 59 5f 9d fc call 0xfc9d5f60
7: 4c 89 ff mov %r15,%rdi
a: be 04 00 00 00 mov $0x4,%esi
f: e8 4c 5f 9d fc call 0xfc9d5f60
14: 43 0f b6 04 26 movzbl (%r14,%r12,1),%eax
19: 84 c0 test %al,%al
1b: 0f 85 a9 00 00 00 jne 0xca
21: 8b 44 24 20 mov 0x20(%rsp),%eax
25: b9 01 00 00 00 mov $0x1,%ecx
* 2a: f0 41 0f b1 4d 00 lock cmpxchg %ecx,0x0(%r13) <-- trapping instruction
30: 75 33 jne 0x65
32: 48 c7 04 24 0e 36 e0 movq $0x45e0360e,(%rsp)
39: 45
3a: 49 rex.WB
3b: c7 .byte 0xc7
3c: 04 1c add $0x1c,%al