syzbot


KASAN: use-after-free Read in dev_map_generic_redirect

Status: premoderation: reported on 2025/01/16 07:29
Reported-by: syzbot+c9b300bf4549cff7bea4@syzkaller.appspotmail.com
First crash: 38d, last: 12h29m
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-1 general protection fault in dev_map_generic_redirect origin:lts syz 83 18d 326d 0/2 premoderation: reported syz repro on 2024/04/02 16:15
linux-5.15 KASAN: use-after-free Read in dev_map_generic_redirect 1 37d 37d 0/3 upstream: reported on 2025/01/16 19:30
linux-6.1 KASAN: use-after-free Read in dev_map_generic_redirect 19 1d21h 187d 0/3 upstream: reported on 2024/08/19 13:49
upstream BUG: unable to handle kernel NULL pointer dereference in dev_map_generic_redirect bpf net 20 221d 321d 0/28 auto-obsoleted due to no activity on 2024/10/01 02:11

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_map_generic_redirect+0xa0/0x6f0 kernel/bpf/devmap.c:667
Read of size 8 at addr ffff888110c6e080 by task kworker/u4:180/19782

CPU: 1 PID: 19782 Comm: kworker/u4:180 Tainted: G        W         5.15.178-syzkaller-00013-g7d1f9b5c2ff5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Workqueue: wg-kex-wg1 wg_packet_handshake_send_worker
Call Trace:
 <IRQ>
 __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
 </IRQ>
 <TASK>
 __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
 </TASK>

Allocated by task 306:
 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]
 kmem_cache_alloc_trace+0x11a/0x270 mm/slub.c:3269
 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
 mld_sendpack+0x4db/0xbb0 net/ipv6/mcast.c:1809
 mld_send_initial_cr net/ipv6/mcast.c:2239 [inline]
 mld_dad_work+0x236/0x620 net/ipv6/mcast.c:2262
 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

Freed by task 0:
 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
 ip_dst_metrics_put include/net/ip.h:528 [inline]
 ip6_dst_destroy+0x8d/0x450 net/ipv6/route.c:360
 dst_destroy+0xbe/0x280 net/core/dst.c:116
 dst_destroy_rcu+0x19/0x20 net/core/dst.c:137
 rcu_do_batch+0x57a/0xc10 kernel/rcu/tree.c:2523
 rcu_core+0x517/0x1020 kernel/rcu/tree.c:2763
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2776
 handle_softirqs+0x25e/0x5c0 kernel/softirq.c:565
 __do_softirq kernel/softirq.c:603 [inline]
 invoke_softirq kernel/softirq.c:425 [inline]
 __irq_exit_rcu+0x52/0xf0 kernel/softirq.c:652
 irq_exit_rcu+0x9/0x10 kernel/softirq.c:664
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline]
 sysvec_apic_timer_interrupt+0xa9/0xc0 arch/x86/kernel/apic/apic.c:1108
 asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:676

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu_common kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x123/0x10b0 kernel/rcu/tree.c:3125
 call_rcu_hurry include/linux/rcupdate.h:89 [inline]
 rcu_sync_call kernel/rcu/sync.c:47 [inline]
 rcu_sync_exit+0xd9/0x1e0 kernel/rcu/sync.c:177
 percpu_up_write+0x5f/0x1d0 kernel/locking/percpu-rwsem.c:299
 mm_drop_all_locks+0x3b8/0x430 mm/mmap.c:3746
 __mmu_notifier_register+0x3bd/0x4c0 mm/mmu_notifier.c:693
 mmu_notifier_register+0x73/0x100 mm/mmu_notifier.c:728
 kvm_init_mmu_notifier virt/kvm/kvm_main.c:862 [inline]
 kvm_create_vm virt/kvm/kvm_main.c:1156 [inline]
 kvm_dev_ioctl_create_vm virt/kvm/kvm_main.c:4754 [inline]
 kvm_dev_ioctl+0xe67/0x1b20 virt/kvm/kvm_main.c:4809
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:860
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:860
 x64_sys_call+0x98/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 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

The buggy address belongs to the object at ffff888110c6e080
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
 96-byte region [ffff888110c6e080, ffff888110c6e0e0)
The buggy address belongs to the page:
page:ffffea0004431b80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x110c6e
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea0004b1e0c0 0000000b0000000b 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 113, ts 4252991440, free_ts 0
 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]
 __kmalloc+0x172/0x2c0 mm/slub.c:4427
 kmalloc include/linux/slab.h:608 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 kobject_get_path+0xbc/0x1f0 lib/kobject.c:184
 kobject_uevent_env+0x27f/0x700 lib/kobject_uevent.c:544
 kobject_synth_uevent+0x4eb/0xae0 lib/kobject_uevent.c:208
 uevent_store+0x25/0x60 drivers/base/core.c:2438
 dev_attr_store+0x5c/0x80 drivers/base/core.c:2136
 sysfs_kf_write+0x123/0x140 fs/sysfs/file.c:139
 kernfs_fop_write_iter+0x2c4/0x410 fs/kernfs/file.c:296
 call_write_iter include/linux/fs.h:2206 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0xd5d/0x1110 fs/read_write.c:594
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888110c6df80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888110c6e000: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff888110c6e080: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                   ^
 ffff888110c6e100: 00 00 00 00 00 00 00 00 02 fc fc fc fc fc fc fc
 ffff888110c6e180: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/02/23 01:11 android13-5.15-lts 7d1f9b5c2ff5 d34966d1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/02/21 18:43 android13-5.15-lts 058abb720bd1 d34966d1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/02/21 18:40 android13-5.15-lts 058abb720bd1 d34966d1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/02/21 18:40 android13-5.15-lts 058abb720bd1 d34966d1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/02/11 16:54 android13-5.15-lts 058abb720bd1 f2baddf5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/01/25 04:00 android13-5.15-lts 829d9f138569 1293872d .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/01/16 07:28 android13-5.15-lts 829d9f138569 968edaf4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect
2025/02/20 19:25 android13-5.15-lts 058abb720bd1 0808a665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 general protection fault in dev_map_generic_redirect
2025/01/25 04:27 android13-5.15-lts 829d9f138569 9fbd772e .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 general protection fault in dev_map_generic_redirect
2025/01/17 11:58 android13-5.15-lts 829d9f138569 953d1c45 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 general protection fault in dev_map_generic_redirect
* Struck through repros no longer work on HEAD.