syzbot


KASAN: use-after-free Read in dev_get_by_index_rcu

Status: fixed on 2020/04/15 17:19
Subsystems: net
[Documentation on labels]
Fix commit: e08ad80551b4 net: add strict checks in netdev_name_node_alt_destroy()
First crash: 1752d, last: 1752d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Read in dev_get_by_index_rcu 1 149d 149d 0/2 auto-obsoleted due to no activity on 2024/10/10 04:32
android-54 KASAN: use-after-free Read in dev_get_by_index_rcu 1 1723d 1723d 0/2 auto-closed as invalid on 2020/07/19 03:31

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_get_by_index_rcu+0x129/0x150 net/core/dev.c:866
Read of size 4 at addr ffff88809280e100 by task syz-executor.0/30842

CPU: 0 PID: 30842 Comm: syz-executor.0 Not tainted 5.6.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:641
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134
 dev_get_by_index_rcu+0x129/0x150 net/core/dev.c:866
 l3mdev_link_scope_lookup+0x7d/0x210 net/l3mdev/l3mdev.c:133
 ip6_route_output_flags_noref+0x300/0x360 net/ipv6/route.c:2469
 ip6_route_output_flags+0x106/0x4d0 net/ipv6/route.c:2500
 ip6_route_output include/net/ip6_route.h:98 [inline]
 ip6_dst_lookup_tail+0x104b/0x1f20 net/ipv6/ip6_output.c:1025
 ip6_dst_lookup_flow+0x8c/0x1d0 net/ipv6/ip6_output.c:1153
 ip6_datagram_dst_update+0x601/0xc80 net/ipv6/datagram.c:88
 __ip6_datagram_connect+0x5e9/0x15d0 net/ipv6/datagram.c:247
 ip6_datagram_connect+0x30/0x50 net/ipv6/datagram.c:271
 inet_dgram_connect+0x14a/0x2d0 net/ipv4/af_inet.c:571
 __sys_connect_file+0x161/0x1c0 net/socket.c:1857
 __sys_connect+0x174/0x1b0 net/socket.c:1874
 __do_sys_connect net/socket.c:1885 [inline]
 __se_sys_connect net/socket.c:1882 [inline]
 __x64_sys_connect+0x73/0xb0 net/socket.c:1882
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c449
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fa3fefb4c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 00007fa3fefb56d4 RCX: 000000000045c449
RDX: 000000000000001c RSI: 0000000020000000 RDI: 0000000000000003
RBP: 000000000076bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000082 R14: 00000000004c2d8a R15: 000000000076bf2c

Allocated by task 10872:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
 __do_kmalloc_node mm/slab.c:3616 [inline]
 __kmalloc_node+0x4e/0x70 mm/slab.c:3623
 kmalloc_node include/linux/slab.h:578 [inline]
 kvmalloc_node+0x68/0x100 mm/util.c:574
 kvmalloc include/linux/mm.h:645 [inline]
 kvzalloc include/linux/mm.h:653 [inline]
 alloc_netdev_mqs+0x98/0xe40 net/core/dev.c:9797
 vti6_init_net+0x244/0x810 net/ipv6/ip6_vti.c:1119
 ops_init+0xb3/0x420 net/core/net_namespace.c:137
 setup_net+0x2d5/0x8b0 net/core/net_namespace.c:327
 copy_net_ns+0x29e/0x5a0 net/core/net_namespace.c:468
 create_new_namespaces+0x403/0xb50 kernel/nsproxy.c:108
 unshare_nsproxy_namespaces+0xc2/0x200 kernel/nsproxy.c:229
 ksys_unshare+0x444/0x980 kernel/fork.c:2955
 __do_sys_unshare kernel/fork.c:3023 [inline]
 __se_sys_unshare kernel/fork.c:3021 [inline]
 __x64_sys_unshare+0x31/0x40 kernel/fork.c:3021
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 30829:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:337 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:476
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 __netdev_name_node_alt_destroy+0x1ff/0x2a0 net/core/dev.c:322
 netdev_name_node_alt_destroy+0x57/0x80 net/core/dev.c:334
 rtnl_alt_ifname net/core/rtnetlink.c:3518 [inline]
 rtnl_linkprop.isra.0+0x575/0x6f0 net/core/rtnetlink.c:3567
 rtnl_dellinkprop+0x46/0x60 net/core/rtnetlink.c:3588
 rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5438
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5456
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:672
 ____sys_sendmsg+0x753/0x880 net/socket.c:2343
 ___sys_sendmsg+0x100/0x170 net/socket.c:2397
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2430
 __do_sys_sendmsg net/socket.c:2439 [inline]
 __se_sys_sendmsg net/socket.c:2437 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2437
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809280e000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 256 bytes inside of
 4096-byte region [ffff88809280e000, ffff88809280f000)
The buggy address belongs to the page:
page:ffffea00024a0380 refcount:1 mapcount:0 mapping:ffff8880aa402000 index:0x0 compound_mapcount: 0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea00024a0308 ffffea0002485a88 ffff8880aa402000
raw: 0000000000000000 ffff88809280e000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809280e000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809280e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809280e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88809280e180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809280e200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/02/20 21:18 upstream ca7e1fd1026c bd2a74a3 .config console log report ci-upstream-kasan-gce-selinux-root
* Struck through repros no longer work on HEAD.