==================================================================
BUG: KASAN: use-after-free in dev_map_generic_redirect+0xa0/0x6f0 kernel/bpf/devmap.c:667
Read of size 8 at addr ffff888126c4ba80 by task kworker/u4:6/1236
CPU: 0 PID: 1236 Comm: kworker/u4:6 Tainted: G W 5.15.176-syzkaller-00972-g829d9f138569 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: wg-kex-wg1 wg_packet_handshake_send_worker
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x151/0x1c0 lib/dump_stack.c:106
print_address_description+0x87/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:427 [inline]
kasan_report+0x179/0x1c0 mm/kasan/report.c:444
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
dev_map_generic_redirect+0xa0/0x6f0 kernel/bpf/devmap.c:667
xdp_do_generic_redirect_map net/core/filter.c:4177 [inline]
xdp_do_generic_redirect+0x42e/0xb40 net/core/filter.c:4236
do_xdp_generic+0x50b/0x7c0 net/core/dev.c:4919
__netif_receive_skb_core+0x1706/0x3640 net/core/dev.c:5324
__netif_receive_skb_one_core net/core/dev.c:5499 [inline]
__netif_receive_skb+0x11c/0x530 net/core/dev.c:5615
process_backlog+0x31c/0x650 net/core/dev.c:6492
__napi_poll+0xc4/0x5a0 net/core/dev.c:7051
napi_poll net/core/dev.c:7118 [inline]
net_rx_action+0x47d/0xc50 net/core/dev.c:7208
handle_softirqs+0x25e/0x5c0 kernel/softirq.c:565
__do_softirq+0xb/0xd kernel/softirq.c:603
do_softirq+0xf6/0x150 kernel/softirq.c:452
__local_bh_enable_ip+0x75/0x80 kernel/softirq.c:379
__raw_read_unlock_bh include/linux/rwlock_api_smp.h:251 [inline]
_raw_read_unlock_bh+0x29/0x30 kernel/locking/spinlock.c:284
wg_socket_send_skb_to_peer+0x178/0x1d0 drivers/net/wireguard/socket.c:184
wg_socket_send_buffer_to_peer+0x11a/0x170 drivers/net/wireguard/socket.c:200
wg_packet_send_handshake_initiation drivers/net/wireguard/send.c:40 [inline]
wg_packet_handshake_send_worker+0x1d4/0x240 drivers/net/wireguard/send.c:51
process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
kthread+0x421/0x510 kernel/kthread.c:337
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
Allocated by task 14033:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:45 [inline]
set_alloc_info mm/kasan/common.c:433 [inline]
____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:512
__kasan_kmalloc+0x9/0x10 mm/kasan/common.c:521
kasan_kmalloc include/linux/kasan.h:227 [inline]
__kmalloc+0x13f/0x2c0 mm/slub.c:4431
__kmalloc_node include/linux/slab.h:469 [inline]
kmalloc_node include/linux/slab.h:626 [inline]
bpf_map_kmalloc_node+0xdb/0x160 kernel/bpf/syscall.c:432
__dev_map_alloc_node+0x5d/0x4a0 kernel/bpf/devmap.c:850
__dev_map_update_elem kernel/bpf/devmap.c:914 [inline]
dev_map_update_elem+0x1eb/0x3c0 kernel/bpf/devmap.c:933
bpf_map_update_value+0x224/0x3c0 kernel/bpf/syscall.c:223
map_update_elem+0x644/0x770 kernel/bpf/syscall.c:1165
__sys_bpf+0x405/0x760 kernel/bpf/syscall.c:4626
__do_sys_bpf kernel/bpf/syscall.c:4742 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4740 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:4740
x64_sys_call+0x87f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:322
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
Freed by task 2871:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
____kasan_slab_free+0x126/0x160 mm/kasan/common.c:365
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:373
kasan_slab_free include/linux/kasan.h:193 [inline]
slab_free_hook mm/slub.c:1723 [inline]
slab_free_freelist_hook+0xbd/0x190 mm/slub.c:1749
slab_free mm/slub.c:3521 [inline]
kfree+0xcc/0x270 mm/slub.c:4583
dev_map_free+0x573/0x6a0 kernel/bpf/devmap.c:237
bpf_map_free_deferred+0x10d/0x1e0 kernel/bpf/syscall.c:481
process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
kthread+0x421/0x510 kernel/kthread.c:337
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
The buggy address belongs to the object at ffff888126c4ba80
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
96-byte region [ffff888126c4ba80, ffff888126c4bae0)
The buggy address belongs to the page:
page:ffffea00049b12c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x126c4b
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea00042ffe00 0000001c0000001c ffff888100042900
raw: 0000000000000000 0000000000200020 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 0x112a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 39, ts 42260335151, free_ts 42223443157
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2605
prep_new_page+0x1b/0x110 mm/page_alloc.c:2611
get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4485
__alloc_pages+0x27e/0x8f0 mm/page_alloc.c:5780
allocate_slab mm/slub.c:1932 [inline]
new_slab+0x9a/0x4e0 mm/slub.c:1995
___slab_alloc+0x39e/0x830 mm/slub.c:3028
__slab_alloc+0x4a/0x90 mm/slub.c:3115
slab_alloc_node mm/slub.c:3206 [inline]
slab_alloc mm/slub.c:3250 [inline]
kmem_cache_alloc_trace+0x147/0x270 mm/slub.c:3267
kmalloc include/linux/slab.h:603 [inline]
dst_cow_metrics_generic+0x55/0x1c0 net/core/dst.c:206
dst_metrics_write_ptr include/net/dst.h:118 [inline]
dst_metric_set include/net/dst.h:179 [inline]
icmp6_dst_alloc+0x385/0x560 net/ipv6/route.c:3288
ndisc_send_skb+0x27f/0xc90 net/ipv6/ndisc.c:491
ndisc_send_rs+0x532/0x6a0 net/ipv6/ndisc.c:705
addrconf_dad_completed+0x8bf/0xd80 net/ipv6/addrconf.c:4298
addrconf_dad_work+0xdc1/0x1710
process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1472 [inline]
free_pcp_prepare mm/page_alloc.c:1544 [inline]
free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3534
free_unref_page+0xe8/0x750 mm/page_alloc.c:3616
free_the_page mm/page_alloc.c:805 [inline]
__free_pages+0x61/0xf0 mm/page_alloc.c:5856
free_pages+0x7c/0x90 mm/page_alloc.c:5867
tlb_batch_list_free mm/mmu_gather.c:61 [inline]
tlb_finish_mmu+0x253/0x320 mm/mmu_gather.c:341
exit_mmap+0x484/0x990 mm/mmap.c:3236
__mmput+0x95/0x310 kernel/fork.c:1180
mmput+0x5b/0x170 kernel/fork.c:1203
exit_mm kernel/exit.c:554 [inline]
do_exit+0xb9c/0x2ca0 kernel/exit.c:867
do_group_exit+0x141/0x310 kernel/exit.c:1002
__do_sys_exit_group kernel/exit.c:1013 [inline]
__se_sys_exit_group kernel/exit.c:1011 [inline]
__x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1011
x64_sys_call+0x610/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:232
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
Memory state around the buggy address:
ffff888126c4b980: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
ffff888126c4ba00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff888126c4ba80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff888126c4bb00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff888126c4bb80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================