syzbot


KASAN: use-after-free Read in veth_napi_del_range

Status: moderation: reported on 2022/11/18 10:22
Reported-by: syzbot+a93d90b4823d3b50e580@syzkaller.appspotmail.com
First crash: 80d, last: 80d

Sample crash report:
bridge0: port 2(bridge_slave_1) entered disabled state
bridge0: port 1(bridge_slave_0) entered disabled state
==================================================================
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 ptr_ring_consume include/linux/ptr_ring.h:332 [inline]
BUG: KASAN: use-after-free in ptr_ring_cleanup include/linux/ptr_ring.h:669 [inline]
BUG: KASAN: use-after-free in veth_napi_del_range+0x4e0/0x560 drivers/net/veth.c:1049
Read of size 8 at addr ffff8880724a7000 by task syz-executor.4/12241

CPU: 1 PID: 12241 Comm: syz-executor.4 Not tainted 6.1.0-rc4-syzkaller-01127-gb4b221bd79a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15e/0x45d mm/kasan/report.c:395
 kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
 __ptr_ring_peek include/linux/ptr_ring.h:172 [inline]
 __ptr_ring_consume include/linux/ptr_ring.h:299 [inline]
 ptr_ring_consume include/linux/ptr_ring.h:332 [inline]
 ptr_ring_cleanup include/linux/ptr_ring.h:669 [inline]
 veth_napi_del_range+0x4e0/0x560 drivers/net/veth.c:1049
 veth_napi_del drivers/net/veth.c:1055 [inline]
 veth_close+0x164/0x500 drivers/net/veth.c:1385
 __dev_close_many+0x1b6/0x2e0 net/core/dev.c:1501
 __dev_close net/core/dev.c:1513 [inline]
 __dev_change_flags+0x2ce/0x750 net/core/dev.c:8528
 dev_change_flags+0x97/0x170 net/core/dev.c:8602
 do_setlink+0x9f1/0x3bb0 net/core/rtnetlink.c:2827
 rtnl_group_changelink net/core/rtnetlink.c:3344 [inline]
 __rtnl_newlink+0xb90/0x1840 net/core/rtnetlink.c:3600
 rtnl_newlink+0x68/0xa0 net/core/rtnetlink.c:3637
 rtnetlink_rcv_msg+0x43e/0xca0 net/core/rtnetlink.c:6141
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x712/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2559
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f8a7fc8b639
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8a809f7168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f8a7fdac050 RCX: 00007f8a7fc8b639
RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000003
RBP: 00007f8a7fce6ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd0e95088f R14: 00007f8a809f7300 R15: 0000000000022000
 </TASK>

Allocated by task 5474:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:371 [inline]
 ____kasan_kmalloc mm/kasan/common.c:330 [inline]
 __kasan_kmalloc+0xa5/0xb0 mm/kasan/common.c:380
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:955 [inline]
 __kmalloc_node+0x5d/0xd0 mm/slab_common.c:962
 kmalloc_node include/linux/slab.h:579 [inline]
 kvmalloc_node+0x43/0x1b0 mm/util.c:581
 kvmalloc include/linux/slab.h:706 [inline]
 kvmalloc_array include/linux/slab.h:724 [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:1005
 veth_napi_enable_range+0xcc/0x190 drivers/net/veth.c:1194
 veth_napi_enable drivers/net/veth.c:1208 [inline]
 veth_xdp_set drivers/net/veth.c:1603 [inline]
 veth_xdp+0x884/0xc70 drivers/net/veth.c:1656
 dev_xdp_install+0xd5/0x2b0 net/core/dev.c:9101
 dev_xdp_attach+0xa30/0x12a0 net/core/dev.c:9249
 dev_change_xdp_fd+0x24a/0x300 net/core/dev.c:9495
 do_setlink+0x31e3/0x3bb0 net/core/rtnetlink.c:3041
 rtnl_group_changelink net/core/rtnetlink.c:3344 [inline]
 __rtnl_newlink+0xb90/0x1840 net/core/rtnetlink.c:3600
 rtnl_newlink+0x68/0xa0 net/core/rtnetlink.c:3637
 rtnetlink_rcv_msg+0x43e/0xca0 net/core/rtnetlink.c:6141
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x712/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2559
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 12241:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:511
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0xaf/0x3b0 mm/slub.c:3674
 kvfree+0x46/0x50 mm/util.c:627
 ptr_ring_cleanup include/linux/ptr_ring.h:671 [inline]
 veth_napi_del_range+0x3af/0x560 drivers/net/veth.c:1049
 veth_napi_del drivers/net/veth.c:1055 [inline]
 veth_close+0x2cd/0x500 drivers/net/veth.c:1382
 __dev_close_many+0x1b6/0x2e0 net/core/dev.c:1501
 __dev_close net/core/dev.c:1513 [inline]
 __dev_change_flags+0x2ce/0x750 net/core/dev.c:8528
 dev_change_flags+0x97/0x170 net/core/dev.c:8602
 do_setlink+0x9f1/0x3bb0 net/core/rtnetlink.c:2827
 rtnl_group_changelink net/core/rtnetlink.c:3344 [inline]
 __rtnl_newlink+0xb90/0x1840 net/core/rtnetlink.c:3600
 rtnl_newlink+0x68/0xa0 net/core/rtnetlink.c:3637
 rtnetlink_rcv_msg+0x43e/0xca0 net/core/rtnetlink.c:6141
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x712/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2559
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff8880724a7000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 0 bytes inside of
 2048-byte region [ffff8880724a7000, ffff8880724a7800)

The buggy address belongs to the physical page:
page:ffffea0001c92800 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880724a3000 pfn:0x724a0
head:ffffea0001c92800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000939408 ffffea00012d2c08 ffff888012042000
raw: ffff8880724a3000 0000000000080006 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3682, tgid 3682 (kworker/1:3), ts 152033222038, free_ts 150416660703
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4288
 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5555
 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2285
 alloc_slab_page mm/slub.c:1794 [inline]
 allocate_slab+0x213/0x300 mm/slub.c:1939
 new_slab mm/slub.c:1992 [inline]
 ___slab_alloc+0xa91/0x1400 mm/slub.c:3180
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3279
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x199/0x3e0 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:954 [inline]
 __kmalloc_node_track_caller+0x4b/0xc0 mm/slab_common.c:975
 kmalloc_reserve net/core/skbuff.c:438 [inline]
 __alloc_skb+0xe9/0x310 net/core/skbuff.c:511
 alloc_skb include/linux/skbuff.h:1269 [inline]
 alloc_skb_with_frags+0x97/0x6c0 net/core/skbuff.c:6138
 sock_alloc_send_pskb+0x7a7/0x930 net/core/sock.c:2733
 sock_alloc_send_skb include/net/sock.h:1884 [inline]
 mld_newpack.isra.0+0x1b9/0x770 net/ipv6/mcast.c:1748
 add_grhead+0x295/0x340 net/ipv6/mcast.c:1851
 add_grec+0x1082/0x1560 net/ipv6/mcast.c:1989
 mld_send_cr net/ipv6/mcast.c:2115 [inline]
 mld_ifc_work+0x456/0xdc0 net/ipv6/mcast.c:2653
 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1509
 free_unref_page_prepare mm/page_alloc.c:3387 [inline]
 free_unref_page+0x1d/0x4d0 mm/page_alloc.c:3483
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x184/0x210 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x66/0x90 mm/kasan/common.c:302
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slab.h:737 [inline]
 slab_alloc_node mm/slub.c:3398 [inline]
 __kmem_cache_alloc_node+0x2e2/0x3e0 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:954 [inline]
 __kmalloc_node_track_caller+0x4b/0xc0 mm/slab_common.c:975
 kstrdup+0x3f/0x70 mm/util.c:61
 device_rename+0x8b/0x230 drivers/base/core.c:4358
 dev_change_name+0x20d/0x6e0 net/core/dev.c:1189
 do_setlink+0x19a9/0x3bb0 net/core/rtnetlink.c:2800
 __rtnl_newlink+0xd69/0x1840 net/core/rtnetlink.c:3590
 rtnl_newlink+0x68/0xa0 net/core/rtnetlink.c:3637
 rtnetlink_rcv_msg+0x43e/0xca0 net/core/rtnetlink.c:6141
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356

Memory state around the buggy address:
 ffff8880724a6f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880724a6f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880724a7000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880724a7080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880724a7100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-net-kasan-gce 2022/11/18 06:50 net-next b4b221bd79a1 4ba8ab94 .config console log report info [disk image] [vmlinux] [kernel image] KASAN: use-after-free Read in veth_napi_del_range
* Struck through repros no longer work on HEAD.