syzbot


KASAN: use-after-free Read in dev_map_generic_redirect

Status: upstream: reported on 2025/01/16 19:30
Reported-by: syzbot+1a1d8462cf1e1aadb857@syzkaller.appspotmail.com
First crash: 69d, last: 1d14h
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 94 3h28m 359d 0/2 premoderation: reported syz repro on 2024/04/02 16:15
linux-6.1 KASAN: use-after-free Read in dev_map_generic_redirect 24 7d11h 220d 0/3 upstream: reported on 2024/08/19 13:49
android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect 12 5d20h 70d 0/2 premoderation: reported on 2025/01/16 07:29
upstream BUG: unable to handle kernel NULL pointer dereference in dev_map_generic_redirect bpf net 20 254d 353d 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+0xa8/0x7b8 kernel/bpf/devmap.c:667
Read of size 8 at addr ffff0000c9b5f300 by task kworker/0:11/4225

CPU: 0 PID: 4225 Comm: kworker/0:11 Not tainted 5.15.179-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Workqueue: wg-crypt-wg1 wg_packet_tx_worker
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x174/0x1e4 mm/kasan/report.c:451
 __asan_report_load8_noabort+0x44/0x50 mm/kasan/report_generic.c:309
 dev_map_generic_redirect+0xa8/0x7b8 kernel/bpf/devmap.c:667
 xdp_do_generic_redirect_map net/core/filter.c:4177 [inline]
 xdp_do_generic_redirect+0x3fc/0xe30 net/core/filter.c:4236
 do_xdp_generic+0x3b8/0x8a8 net/core/dev.c:4942
 __netif_receive_skb_core+0x15c4/0x3420 net/core/dev.c:5347
 __netif_receive_skb_one_core net/core/dev.c:5522 [inline]
 __netif_receive_skb+0x114/0x400 net/core/dev.c:5638
 process_backlog+0x3ec/0x7e0 net/core/dev.c:6515
 __napi_poll+0xb4/0x624 net/core/dev.c:7074
 napi_poll net/core/dev.c:7141 [inline]
 net_rx_action+0x500/0xc10 net/core/dev.c:7231
 handle_softirqs+0x384/0xdbc kernel/softirq.c:558
 __do_softirq kernel/softirq.c:592 [inline]
 do_softirq_own_stack include/asm-generic/softirq_stack.h:10 [inline]
 do_softirq+0xfc/0x1b0 kernel/softirq.c:459
 __local_bh_enable_ip+0x298/0x470 kernel/softirq.c:383
 __raw_read_unlock_bh include/linux/rwlock_api_smp.h:251 [inline]
 _raw_read_unlock_bh+0xf8/0x180 kernel/locking/spinlock.c:284
 wg_socket_send_skb_to_peer+0x158/0x1a8 drivers/net/wireguard/socket.c:184
 wg_packet_create_data_done drivers/net/wireguard/send.c:251 [inline]
 wg_packet_tx_worker+0x1a8/0x714 drivers/net/wireguard/send.c:276
 process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
 worker_thread+0x910/0x1034 kernel/workqueue.c:2457
 kthread+0x37c/0x45c kernel/kthread.c:334
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

Allocated by task 5906:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xbc/0xfc mm/kasan/common.c:513
 __kasan_kmalloc+0x10/0x1c mm/kasan/common.c:522
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc_node+0x2c0/0x5b8 mm/slub.c:4455
 kmalloc_node include/linux/slab.h:614 [inline]
 bpf_map_kmalloc_node+0x22c/0x5c0 kernel/bpf/syscall.c:430
 __dev_map_alloc_node+0x70/0x438 kernel/bpf/devmap.c:850
 __dev_map_update_elem kernel/bpf/devmap.c:914 [inline]
 dev_map_update_elem+0x190/0x35c kernel/bpf/devmap.c:933
 bpf_map_update_value+0x6a8/0x8fc kernel/bpf/syscall.c:221
 map_update_elem+0x52c/0x6a0 kernel/bpf/syscall.c:1185
 __sys_bpf+0x2a4/0x610 kernel/bpf/syscall.c:4636
 __do_sys_bpf kernel/bpf/syscall.c:4752 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4750 [inline]
 __arm64_sys_bpf+0x80/0x98 kernel/bpf/syscall.c:4750
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Freed by task 4225:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
 kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
 ____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0x178/0x410 mm/slub.c:4559
 dev_map_free+0x4b0/0x608 kernel/bpf/devmap.c:237
 bpf_map_free_deferred+0x2cc/0x430 kernel/bpf/syscall.c:479
 process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
 worker_thread+0x910/0x1034 kernel/workqueue.c:2457
 kthread+0x37c/0x45c kernel/kthread.c:334
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

Last potentially related work creation:
 kasan_save_stack+0x38/0x68 mm/kasan/common.c:38
 kasan_record_aux_stack+0xd4/0x11c mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x118/0xb40 kernel/rcu/tree.c:3087
 inet_free_ifa net/ipv4/devinet.c:231 [inline]
 inetdev_destroy net/ipv4/devinet.c:321 [inline]
 inetdev_event+0x450/0x1270 net/ipv4/devinet.c:1612
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd4/0x164 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2049 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2061 [inline]
 call_netdevice_notifiers net/core/dev.c:2075 [inline]
 unregister_netdevice_many+0xec8/0x18a8 net/core/dev.c:11133
 default_device_exit_batch+0x4c0/0x520 net/core/dev.c:11666
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x6bc/0xa9c net/core/net_namespace.c:618
 process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
 worker_thread+0x910/0x1034 kernel/workqueue.c:2457
 kthread+0x37c/0x45c kernel/kthread.c:334
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

The buggy address belongs to the object at ffff0000c9b5f300
 which belongs to the cache kmalloc-cg-128 of size 128
The buggy address is located 0 bytes inside of
 128-byte region [ffff0000c9b5f300, ffff0000c9b5f380)
The buggy address belongs to the page:
page:000000006afc01b6 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x109b5f
memcg:ffff0000d600c301
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 dead000000000100 dead000000000122 ffff0000c0002d80
raw: 0000000000000000 0000000000100010 00000001ffffffff ffff0000d600c301
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000c9b5f200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000c9b5f280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000c9b5f300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff0000c9b5f380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000c9b5f400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/03/21 19:46 linux-5.15.y 0c935c049b5c 62330552 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in dev_map_generic_redirect
2025/03/19 16:46 linux-5.15.y 0c935c049b5c e20d7b13 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in dev_map_generic_redirect
2025/01/16 19:29 linux-5.15.y 4735586da88e f9e07a6e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in dev_map_generic_redirect
2025/03/26 03:23 linux-5.15.y 0c935c049b5c 89d30d73 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan general protection fault in dev_map_generic_redirect
2025/03/20 05:20 linux-5.15.y 0c935c049b5c 9209bc22 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 BUG: unable to handle kernel paging request in dev_map_generic_redirect
2025/03/12 20:26 linux-5.15.y c16c81c81336 1a5d9317 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 BUG: unable to handle kernel paging request in dev_map_generic_redirect
* Struck through repros no longer work on HEAD.