syzbot


KASAN: use-after-free Read in veth_xdp_rcv

Status: upstream: reported C repro on 2021/10/09 12:40
Reported-by: syzbot+67f89551088ea1a6850e@syzkaller.appspotmail.com
First crash: 310d, last: 240d

Cause bisection: the cause commit could be any of (bisect log):
  56b06d4da812 rtlwifi: btcoex: remove redundant initialization of variables ant_num and single_ant_path
  98f80899e168 Merge tag 'mt76-for-kvalo-2020-07-21' of https://github.com/nbd168/wireless
  1751a7352b63 rtlwifi: btcoex: use %*ph to print small buffer

Fix bisection: fixed by (bisect log) :
commit 2cbad989033bff0256675c38f96f5faab852af4b
Author: Paolo Abeni <pabeni@redhat.com>
Date: Tue Nov 30 10:08:06 2021 +0000

  bpf: Do not WARN in bpf_warn_invalid_xdp_action()

Patch testing requests:
Created Duration User Patch Repo Result
2021/11/18 15:18 18m pabeni@redhat.com https://github.com/pabeni/mptcp.git napi_bpf_fixup OK
2021/11/11 09:48 10m pabeni@redhat.com https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master report log
2021/11/08 11:59 10m pabeni@redhat.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __ptr_ring_peek include/linux/ptr_ring.h:172 [inline]
BUG: KASAN: use-after-free in __ptr_ring_consume include/linux/ptr_ring.h:299 [inline]
BUG: KASAN: use-after-free in veth_xdp_rcv+0x70b/0x810 drivers/net/veth.c:856
Read of size 8 at addr ffff88807af6e008 by task ksoftirqd/0/13

CPU: 0 PID: 13 Comm: ksoftirqd/0 Not tainted 5.15.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 __ptr_ring_peek include/linux/ptr_ring.h:172 [inline]
 __ptr_ring_consume include/linux/ptr_ring.h:299 [inline]
 veth_xdp_rcv+0x70b/0x810 drivers/net/veth.c:856
 veth_poll+0x134/0x850 drivers/net/veth.c:913
 __napi_poll+0xaf/0x440 net/core/dev.c:6993
 napi_poll net/core/dev.c:7060 [inline]
 net_rx_action+0x801/0xb40 net/core/dev.c:7147
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558
 run_ksoftirqd kernel/softirq.c:920 [inline]
 run_ksoftirqd+0x2d/0x60 kernel/softirq.c:912
 smpboot_thread_fn+0x645/0x9c0 kernel/smpboot.c:164
 kthread+0x3e5/0x4d0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Allocated by task 7543:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc mm/kasan/common.c:513 [inline]
 ____kasan_kmalloc mm/kasan/common.c:472 [inline]
 __kasan_kmalloc+0xa4/0xd0 mm/kasan/common.c:522
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x61/0x120 mm/util.c:587
 kvmalloc include/linux/mm.h:805 [inline]
 kvmalloc_array include/linux/mm.h:823 [inline]
 __ptr_ring_init_queue_alloc include/linux/ptr_ring.h:471 [inline]
 ptr_ring_init include/linux/ptr_ring.h:489 [inline]
 __veth_napi_enable_range+0xa2/0x780 drivers/net/veth.c:941
 __veth_napi_enable drivers/net/veth.c:964 [inline]
 veth_enable_xdp+0x30f/0x620 drivers/net/veth.c:1068
 veth_xdp_set drivers/net/veth.c:1483 [inline]
 veth_xdp+0x4d4/0x780 drivers/net/veth.c:1523
 dev_xdp_install+0xd5/0x270 net/core/dev.c:9365
 dev_xdp_attach+0x83d/0x1010 net/core/dev.c:9513
 dev_xdp_attach_link net/core/dev.c:9532 [inline]
 bpf_xdp_link_attach+0x262/0x410 net/core/dev.c:9695
 link_create kernel/bpf/syscall.c:4268 [inline]
 __sys_bpf+0x549c/0x5df0 kernel/bpf/syscall.c:4667
 __do_sys_bpf kernel/bpf/syscall.c:4701 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4699 [inline]
 __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4699
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 7542:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:360
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free mm/kasan/common.c:328 [inline]
 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x81/0x190 mm/slub.c:1725
 slab_free mm/slub.c:3483 [inline]
 kfree+0xe4/0x530 mm/slub.c:4543
 kvfree+0x42/0x50 mm/util.c:620
 ptr_ring_cleanup include/linux/ptr_ring.h:671 [inline]
 veth_napi_del_range+0x3aa/0x560 drivers/net/veth.c:985
 veth_napi_del drivers/net/veth.c:991 [inline]
 veth_disable_xdp+0x2b3/0x430 drivers/net/veth.c:1101
 veth_xdp_set drivers/net/veth.c:1499 [inline]
 veth_xdp+0x698/0x780 drivers/net/veth.c:1523
 dev_xdp_install+0x1ed/0x270 net/core/dev.c:9365
 dev_xdp_detach_link net/core/dev.c:9549 [inline]
 bpf_xdp_link_release+0x242/0x4e0 net/core/dev.c:9564
 bpf_link_free+0xe6/0x1b0 kernel/bpf/syscall.c:2427
 bpf_link_put+0x161/0x1b0 kernel/bpf/syscall.c:2453
 bpf_link_release+0x33/0x40 kernel/bpf/syscall.c:2461
 __fput+0x288/0x9f0 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
 exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff88807af6e000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 8 bytes inside of
 2048-byte region [ffff88807af6e000, ffff88807af6e800)
The buggy address belongs to the page:
page:ffffea0001ebda00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7af68
head:ffffea0001ebda00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c42000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd28c0(GFP_NOWAIT|__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 7536, ts 1019839663090, free_ts 1019749588025
 prep_new_page mm/page_alloc.c:2424 [inline]
 get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4153
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5375
 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2197
 alloc_slab_page mm/slub.c:1763 [inline]
 allocate_slab mm/slub.c:1900 [inline]
 new_slab+0x319/0x490 mm/slub.c:1963
 ___slab_alloc+0x921/0xfe0 mm/slub.c:2994
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3081
 slab_alloc_node mm/slub.c:3172 [inline]
 __kmalloc_node_track_caller+0x2d2/0x340 mm/slub.c:4936
 kmalloc_reserve net/core/skbuff.c:352 [inline]
 pskb_expand_head+0x15e/0x1060 net/core/skbuff.c:1699
 netlink_trim+0x1ea/0x240 net/netlink/af_netlink.c:1296
 netlink_broadcast+0x5b/0xd50 net/netlink/af_netlink.c:1492
 nlmsg_multicast include/net/netlink.h:1033 [inline]
 nlmsg_notify+0x8f/0x280 net/netlink/af_netlink.c:2528
 rtnl_notify net/core/rtnetlink.c:730 [inline]
 rtmsg_ifinfo_send net/core/rtnetlink.c:3833 [inline]
 rtmsg_ifinfo_event net/core/rtnetlink.c:3848 [inline]
 rtmsg_ifinfo_event net/core/rtnetlink.c:3836 [inline]
 rtnetlink_event+0x193/0x1d0 net/core/rtnetlink.c:5623
 notifier_call_chain+0xb5/0x200 kernel/notifier.c:83
 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1996
 call_netdevice_notifiers_extack net/core/dev.c:2008 [inline]
 call_netdevice_notifiers net/core/dev.c:2022 [inline]
 netdev_features_change net/core/dev.c:1368 [inline]
 netdev_update_features net/core/dev.c:10035 [inline]
 netdev_update_features+0xc4/0xd0 net/core/dev.c:10032
 veth_xdp_set drivers/net/veth.c:1510 [inline]
 veth_xdp+0x448/0x780 drivers/net/veth.c:1523
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1338 [inline]
 free_pcp_prepare+0x2c5/0x780 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3315 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3394
 __unfreeze_partials+0x340/0x360 mm/slub.c:2495
 qlink_free mm/kasan/quarantine.c:146 [inline]
 qlist_free_all+0x5a/0xc0 mm/kasan/quarantine.c:165
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x95/0xb0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3214 [inline]
 kmem_cache_alloc+0x209/0x390 mm/slub.c:3219
 vm_area_dup+0x88/0x2b0 kernel/fork.c:357
 __split_vma+0xa5/0x550 mm/mmap.c:2714
 split_vma+0x95/0xd0 mm/mmap.c:2772
 mprotect_fixup+0x678/0x940 mm/mprotect.c:477
 do_mprotect_pkey+0x558/0x9a0 mm/mprotect.c:636
 __do_sys_mprotect mm/mprotect.c:662 [inline]
 __se_sys_mprotect mm/mprotect.c:659 [inline]
 __x64_sys_mprotect+0x74/0xb0 mm/mprotect.c:659
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff88807af6df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807af6df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807af6e000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88807af6e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807af6e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (17):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-bpf-next-kasan-gce 2021/10/28 21:07 bpf-next 252c765bd764 be531bb4 .config log report syz C KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-kasan-gce 2021/11/11 19:36 bpf fceb07950a7a 75b04091 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-kasan-gce 2021/11/11 17:27 bpf fceb07950a7a 75b04091 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-kasan-gce 2021/11/08 13:24 bpf 47b3708c6088 d29682f1 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/11/13 13:43 bpf-next 325d956d6717 83f5c9b5 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/11/12 18:52 bpf-next 7cc595a60187 83f5c9b5 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/11/10 18:51 bpf-next 5577f24cb04a 75b04091 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-net-kasan-gce 2021/11/08 11:57 net-next cc0356d6a02e d29682f1 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/11/08 06:05 bpf-next 5577f24cb04a 4c1be0be .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/11/08 04:12 bpf-next 5577f24cb04a 4c1be0be .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/11/02 02:32 bpf-next 36e70b9b06bf 098b5d53 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-net-kasan-gce 2021/10/28 09:02 net-next 911e3a46fb38 be531bb4 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/10/22 10:19 bpf-next 29da17c48886 55f90bc6 .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-bpf-next-kasan-gce 2021/10/07 22:47 bpf-next af4bb50d4647 efe0f24d .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-linux-next-kasan-gce-root 2021/11/10 02:01 linux-next c8109c2ba35e 55fa030c .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-linux-next-kasan-gce-root 2021/11/09 21:39 linux-next c8109c2ba35e 59bcaf9a .config log report info KASAN: use-after-free Read in veth_xdp_rcv
ci-upstream-linux-next-kasan-gce-root 2021/10/04 09:27 linux-next a25006a77348 ce697b49 .config log report info KASAN: use-after-free Read in veth_xdp_rcv