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: 20d, last: 20d
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 22h00m 309d 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 16 1d19h 170d 0/3 upstream: reported on 2024/08/19 13:49
android-5-15 KASAN: use-after-free Read in dev_map_generic_redirect 4 11d 20d 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 204d 303d 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 ffff0000e5e81400 by task kworker/1:3/4070

CPU: 1 PID: 4070 Comm: kworker/1:3 Not tainted 5.15.176-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: wg-crypt-wg0 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+0x3f8/0xe2c net/core/filter.c:4236
 do_xdp_generic+0x3b8/0x8a8 net/core/dev.c:4911
 __netif_receive_skb_core+0x15c4/0x341c net/core/dev.c:5316
 __netif_receive_skb_one_core net/core/dev.c:5491 [inline]
 __netif_receive_skb+0x114/0x400 net/core/dev.c:5607
 process_backlog+0x3ec/0x7e0 net/core/dev.c:6484
 __napi_poll+0xb4/0x624 net/core/dev.c:7043
 napi_poll net/core/dev.c:7110 [inline]
 net_rx_action+0x500/0xc10 net/core/dev.c:7200
 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 7198:
 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:4644
 __do_sys_bpf kernel/bpf/syscall.c:4760 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4758 [inline]
 __arm64_sys_bpf+0x80/0x98 kernel/bpf/syscall.c:4758
 __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 4070:
 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

The buggy address belongs to the object at ffff0000e5e81400
 which belongs to the cache kmalloc-cg-128 of size 128
The buggy address is located 0 bytes inside of
 128-byte region [ffff0000e5e81400, ffff0000e5e81480)
The buggy address belongs to the page:
page:00000000ddfb73a6 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x125e81
memcg:ffff0000c2e8f101
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 fffffc00033ab580 0000000500000004 ffff0000c0002d80
raw: 0000000000000000 0000000000100010 00000001ffffffff ffff0000c2e8f101
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000e5e81300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000e5e81380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000e5e81400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff0000e5e81480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000e5e81500: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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
* Struck through repros no longer work on HEAD.