==================================================================
BUG: KASAN: use-after-free in cpu_map_generic_redirect+0x1c7/0x780 kernel/bpf/cpumap.c:788
Read of size 8 at addr ffff88812d65e518 by task syz.2.479/1481
CPU: 0 PID: 1481 Comm: syz.2.479 Not tainted 6.1.112-syzkaller-00003-gd3daafbfd2bf #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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:4402 [inline]
xdp_do_generic_redirect+0x3df/0xb40 net/core/filter.c:4449
do_xdp_generic+0x53e/0x800 net/core/dev.c:4958
__netif_receive_skb_core+0x19ae/0x43d0 net/core/dev.c:5365
__netif_receive_skb_one_core net/core/dev.c:5542 [inline]
__netif_receive_skb+0x11c/0x530 net/core/dev.c:5658
netif_receive_skb_internal net/core/dev.c:5744 [inline]
netif_receive_skb+0xb0/0x480 net/core/dev.c:5803
tun_rx_batched+0x1c0/0x8f0 drivers/net/tun.c:1548
tun_get_user+0x287e/0x3a90 drivers/net/tun.c:1998
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+0xaf6/0xed0 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:0x7f4d2617d1ff
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:00007f4d27046000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f4d26335f80 RCX: 00007f4d2617d1ff
RDX: 000000000000006a RSI: 0000000020000180 RDI: 00000000000000c8
RBP: 00007f4d261f139e R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000006a R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4d26335f80 R15: 00007ffe3a6fc3b8
Allocated by task 1206:
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]
__do_kmalloc_node mm/slab_common.c:938 [inline]
__kmalloc_node+0xb4/0x1e0 mm/slab_common.c:945
kmalloc_node include/linux/slab.h:583 [inline]
bpf_map_kmalloc_node+0xd0/0x2c0 kernel/bpf/syscall.c:454
__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:190
map_update_elem+0x500/0x680 kernel/bpf/syscall.c:1443
__sys_bpf+0x460/0x7f0 kernel/bpf/syscall.c:4990
__do_sys_bpf kernel/bpf/syscall.c:5106 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5104 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5104
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 1207:
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:241
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
kasan_slab_free include/linux/kasan.h:178 [inline]
slab_free_hook mm/slub.c:1745 [inline]
slab_free_freelist_hook mm/slub.c:1771 [inline]
slab_free mm/slub.c:3684 [inline]
__kmem_cache_free+0x218/0x3b0 mm/slub.c:3697
kfree+0x7a/0xf0 mm/slab_common.c:990
put_cpu_map_entry+0x6e2/0x760 kernel/bpf/cpumap.c:161
cpu_map_kthread_run+0x2463/0x2520 kernel/bpf/cpumap.c:408
kthread+0x26d/0x300 kernel/kthread.c:386
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
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:637
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:295
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:2807 [inline]
call_rcu+0xdc/0x10f0 kernel/rcu/tree.c:2926
__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:637
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:295
The buggy address belongs to the object at ffff88812d65e500
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 24 bytes inside of
192-byte region [ffff88812d65e500, ffff88812d65e5c0)
The buggy address belongs to the physical page:
page:ffffea0004b59780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12d65e
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea0004b8f8c0 dead000000000002 ffff888100042c00
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 295, tgid 295 (syz-executor), ts 23784888634, free_ts 0
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+0x2980/0x2a10 mm/page_alloc.c:4439
__alloc_pages+0x234/0x610 mm/page_alloc.c:5728
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
__do_kmalloc_node mm/slab_common.c:937 [inline]
__kmalloc_node_track_caller+0xa2/0x1e0 mm/slab_common.c:958
kmemdup+0x29/0x60 mm/util.c:134
_Z7kmemdupPKvU17pass_object_size0mj include/linux/fortify-string.h:585 [inline]
neigh_parms_alloc+0x81/0x530 net/core/neighbour.c:1706
inetdev_init+0x146/0x4e0 net/ipv4/devinet.c:269
inetdev_event+0x205/0x1110 net/ipv4/devinet.c:1534
notifier_call_chain kernel/notifier.c:87 [inline]
raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:455
call_netdevice_notifiers_info net/core/dev.c:1978 [inline]
call_netdevice_notifiers_extack net/core/dev.c:2016 [inline]
call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2030
page_owner free stack trace missing
Memory state around the buggy address:
ffff88812d65e400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88812d65e480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88812d65e500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88812d65e580: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88812d65e600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
================================================================================
UBSAN: array-index-out-of-bounds in kernel/locking/qspinlock.c:131:9
index 16382 is out of range for type 'unsigned long[8]'
CPU: 0 PID: 1481 Comm: syz.2.479 Tainted: G B 6.1.112-syzkaller-00003-gd3daafbfd2bf #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
dump_stack+0x15/0x1e lib/dump_stack.c:113
ubsan_epilogue lib/ubsan.c:151 [inline]
__ubsan_handle_out_of_bounds+0x13a/0x160 lib/ubsan.c:282
decode_tail kernel/locking/qspinlock.c:131 [inline]
__pv_queued_spin_lock_slowpath+0xb96/0xda0 kernel/locking/qspinlock.c:471
pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:591 [inline]
queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
queued_spin_lock include/asm-generic/qspinlock.h:114 [inline]
do_raw_spin_lock include/linux/spinlock.h:187 [inline]
__raw_spin_lock include/linux/spinlock_api_smp.h:134 [inline]
_raw_spin_lock+0x139/0x1b0 kernel/locking/spinlock.c:154
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:4402 [inline]
xdp_do_generic_redirect+0x3df/0xb40 net/core/filter.c:4449
do_xdp_generic+0x53e/0x800 net/core/dev.c:4958
__netif_receive_skb_core+0x19ae/0x43d0 net/core/dev.c:5365
__netif_receive_skb_one_core net/core/dev.c:5542 [inline]
__netif_receive_skb+0x11c/0x530 net/core/dev.c:5658
netif_receive_skb_internal net/core/dev.c:5744 [inline]
netif_receive_skb+0xb0/0x480 net/core/dev.c:5803
tun_rx_batched+0x1c0/0x8f0 drivers/net/tun.c:1548
tun_get_user+0x287e/0x3a90 drivers/net/tun.c:1998
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+0xaf6/0xed0 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:0x7f4d2617d1ff
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:00007f4d27046000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f4d26335f80 RCX: 00007f4d2617d1ff
RDX: 000000000000006a RSI: 0000000020000180 RDI: 00000000000000c8
RBP: 00007f4d261f139e R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000006a R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4d26335f80 R15: 00007ffe3a6fc3b8
================================================================================
general protection fault, probably for non-canonical address 0xe01259df9f54ec77: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0x0092eefcfaa763b8-0x0092eefcfaa763bf]
CPU: 0 PID: 1481 Comm: syz.2.479 Tainted: G B 6.1.112-syzkaller-00003-gd3daafbfd2bf #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:__pv_queued_spin_lock_slowpath+0x2f5/0xda0 kernel/locking/qspinlock.c:474
Code: 4c 89 e8 48 c1 e8 03 80 3c 10 00 74 12 4c 89 ef e8 d0 d4 9b fc 48 ba 00 00 00 00 00 fc ff df 49 03 5d 00 48 89 d8 48 c1 e8 03 <80> 3c 10 00 74 12 48 89 df e8 4d d5 9b fc 48 ba 00 00 00 00 00 fc
RSP: 0018:ffffc9000f1ef000 EFLAGS: 00010207
RAX: 00125ddf9f54ec77 RBX: 0092eefcfaa763bc RCX: 0000000000040000
RDX: dffffc0000000000 RSI: 000000000003ffff RDI: 0000000000040000
RBP: ffffc9000f1ef0f0 R08: ffffffff81449e3b R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: 1ffff11025acbc20
R13: ffffffff86768880 R14: 1ffff1103edc7179 R15: ffff88812d65e104
FS: 00007f4d270466c0(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000110c2de68a CR3: 000000011f94e000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:591 [inline]
queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
queued_spin_lock include/asm-generic/qspinlock.h:114 [inline]
do_raw_spin_lock include/linux/spinlock.h:187 [inline]
__raw_spin_lock include/linux/spinlock_api_smp.h:134 [inline]
_raw_spin_lock+0x139/0x1b0 kernel/locking/spinlock.c:154
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:4402 [inline]
xdp_do_generic_redirect+0x3df/0xb40 net/core/filter.c:4449
do_xdp_generic+0x53e/0x800 net/core/dev.c:4958
__netif_receive_skb_core+0x19ae/0x43d0 net/core/dev.c:5365
__netif_receive_skb_one_core net/core/dev.c:5542 [inline]
__netif_receive_skb+0x11c/0x530 net/core/dev.c:5658
netif_receive_skb_internal net/core/dev.c:5744 [inline]
netif_receive_skb+0xb0/0x480 net/core/dev.c:5803
tun_rx_batched+0x1c0/0x8f0 drivers/net/tun.c:1548
tun_get_user+0x287e/0x3a90 drivers/net/tun.c:1998
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+0xaf6/0xed0 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:0x7f4d2617d1ff
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:00007f4d27046000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f4d26335f80 RCX: 00007f4d2617d1ff
RDX: 000000000000006a RSI: 0000000020000180 RDI: 00000000000000c8
RBP: 00007f4d261f139e R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000006a R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4d26335f80 R15: 00007ffe3a6fc3b8
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__pv_queued_spin_lock_slowpath+0x2f5/0xda0 kernel/locking/qspinlock.c:474
Code: 4c 89 e8 48 c1 e8 03 80 3c 10 00 74 12 4c 89 ef e8 d0 d4 9b fc 48 ba 00 00 00 00 00 fc ff df 49 03 5d 00 48 89 d8 48 c1 e8 03 <80> 3c 10 00 74 12 48 89 df e8 4d d5 9b fc 48 ba 00 00 00 00 00 fc
RSP: 0018:ffffc9000f1ef000 EFLAGS: 00010207
RAX: 00125ddf9f54ec77 RBX: 0092eefcfaa763bc RCX: 0000000000040000
RDX: dffffc0000000000 RSI: 000000000003ffff RDI: 0000000000040000
RBP: ffffc9000f1ef0f0 R08: ffffffff81449e3b R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: 1ffff11025acbc20
R13: ffffffff86768880 R14: 1ffff1103edc7179 R15: ffff88812d65e104
FS: 00007f4d270466c0(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000110c2de68a CR3: 000000011f94e000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 4c 89 e8 mov %r13,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 10 00 cmpb $0x0,(%rax,%rdx,1)
b: 74 12 je 0x1f
d: 4c 89 ef mov %r13,%rdi
10: e8 d0 d4 9b fc call 0xfc9bd4e5
15: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
1c: fc ff df
1f: 49 03 5d 00 add 0x0(%r13),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 80 3c 10 00 cmpb $0x0,(%rax,%rdx,1) <-- trapping instruction
2e: 74 12 je 0x42
30: 48 89 df mov %rbx,%rdi
33: e8 4d d5 9b fc call 0xfc9bd585
38: 48 rex.W
39: ba 00 00 00 00 mov $0x0,%edx
3e: 00 fc add %bh,%ah