syzbot


KASAN: use-after-free Read in ipv6_chk_addr_and_flags

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: 1580d, last: 1580d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_net include/linux/netdevice.h:2220 [inline]
BUG: KASAN: use-after-free in ipv6_chk_addr_and_flags+0x6cb/0x800 net/ipv6/addrconf.c:1919
Read of size 8 at addr ffff888065e1e588 by task syz-executor.1/30365

CPU: 1 PID: 30365 Comm: syz-executor.1 Not tainted 5.6.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __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_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 dev_net include/linux/netdevice.h:2220 [inline]
 ipv6_chk_addr_and_flags+0x6cb/0x800 net/ipv6/addrconf.c:1919
 ipv6_chk_addr+0x3a/0x50 net/ipv6/addrconf.c:1889
 icmp6_send+0x2e1/0x1f90 net/ipv6/icmp.c:458
 icmpv6_send+0xec/0x220 net/ipv6/ip6_icmp.c:43
 ip6_link_failure+0x2b/0x530 net/ipv6/route.c:2643
 dst_link_failure include/net/dst.h:419 [inline]
 ip_tunnel_xmit+0x1738/0x2d0c net/ipv4/ip_tunnel.c:824
 __gre_xmit+0x5e9/0x9a0 net/ipv4/ip_gre.c:448
 erspan_xmit+0x912/0x28f0 net/ipv4/ip_gre.c:683
 __netdev_start_xmit include/linux/netdevice.h:4524 [inline]
 netdev_start_xmit include/linux/netdevice.h:4538 [inline]
 xmit_one net/core/dev.c:3470 [inline]
 dev_hard_start_xmit+0x1a3/0x9b0 net/core/dev.c:3486
 sch_direct_xmit+0x372/0xd30 net/sched/sch_generic.c:313
 __dev_xmit_skb net/core/dev.c:3671 [inline]
 __dev_queue_xmit+0x2707/0x35c0 net/core/dev.c:4032
 dev_queue_xmit+0x18/0x20 net/core/dev.c:4096
 neigh_resolve_output net/core/neighbour.c:1487 [inline]
 neigh_resolve_output+0x5c4/0x990 net/core/neighbour.c:1467
 neigh_output include/net/neighbour.h:510 [inline]
 ip6_finish_output2+0x109a/0x25c0 net/ipv6/ip6_output.c:116
 __ip6_finish_output+0x444/0xaa0 net/ipv6/ip6_output.c:142
 ip6_finish_output+0x38/0x1f0 net/ipv6/ip6_output.c:152
 NF_HOOK_COND include/linux/netfilter.h:296 [inline]
 ip6_output+0x25e/0x880 net/ipv6/ip6_output.c:175
 dst_output include/net/dst.h:436 [inline]
 NF_HOOK include/linux/netfilter.h:307 [inline]
 NF_HOOK include/linux/netfilter.h:301 [inline]
 mld_sendpack+0x9c2/0xed0 net/ipv6/mcast.c:1682
 mld_send_cr net/ipv6/mcast.c:1978 [inline]
 mld_ifc_timer_expire+0x454/0x950 net/ipv6/mcast.c:2477
 call_timer_fn+0x1ac/0x780 kernel/time/timer.c:1404
 expire_timers kernel/time/timer.c:1449 [inline]
 __run_timers kernel/time/timer.c:1773 [inline]
 __run_timers kernel/time/timer.c:1740 [inline]
 run_timer_softirq+0x6c3/0x1790 kernel/time/timer.c:1786
 __do_softirq+0x262/0x98c kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x19b/0x1e0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:546 [inline]
 smp_apic_timer_interrupt+0x1a3/0x610 arch/x86/kernel/apic/apic.c:1146
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
 </IRQ>
RIP: 0010:__sanitizer_cov_trace_pc+0x26/0x50 kernel/kcov.c:187
Code: 00 00 00 00 55 48 89 e5 65 48 8b 04 25 c0 1e 02 00 65 8b 15 44 8d 8c 7e 81 e2 00 01 1f 00 48 8b 75 08 75 2b 8b 90 80 13 00 00 <83> fa 02 75 20 48 8b 88 88 13 00 00 8b 80 84 13 00 00 48 8b 11 48
RSP: 0018:ffffc90005c17730 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: ffff88804fa72040 RBX: fff0000000000fff RCX: ffffffff81a39c5d
RDX: 0000000000000000 RSI: ffffffff81a39c75 RDI: 0000000000000007
RBP: ffffc90005c17730 R08: ffff88804fa72040 R09: ffffed1009f4e409
R10: ffffed1009f4e408 R11: ffff88804fa72047 R12: 8000000066fdf007
R13: ffff8880518f5e08 R14: dffffc0000000000 R15: 00007f4b21400000
 pte_flags arch/x86/include/asm/pgtable_types.h:457 [inline]
 pte_present arch/x86/include/asm/pgtable.h:735 [inline]
 zap_pte_range mm/memory.c:1050 [inline]
 zap_pmd_range mm/memory.c:1184 [inline]
 zap_pud_range mm/memory.c:1213 [inline]
 zap_p4d_range mm/memory.c:1234 [inline]
 unmap_page_range+0x955/0x28d0 mm/memory.c:1255
 unmap_single_vma+0x19d/0x300 mm/memory.c:1300
 unmap_vmas+0x184/0x2f0 mm/memory.c:1332
 exit_mmap+0x2ba/0x530 mm/mmap.c:3130
 __mmput kernel/fork.c:1082 [inline]
 mmput+0x179/0x4d0 kernel/fork.c:1103
 exit_mm kernel/exit.c:485 [inline]
 do_exit+0xac2/0x2f50 kernel/exit.c:788
 do_group_exit+0x135/0x360 kernel/exit.c:899
 get_signal+0x47c/0x24f0 kernel/signal.c:2734
 do_signal+0x87/0x1700 arch/x86/kernel/signal.c:813
 exit_to_usermode_loop+0x286/0x380 arch/x86/entry/common.c:160
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:278 [inline]
 do_syscall_64+0x676/0x790 arch/x86/entry/common.c:304
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c6c9
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:00007f4b20f9dcf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 000000000076bfd0 RCX: 000000000045c6c9
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 000000000076bfd0
RBP: 000000000076bfc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000076bfd4
R13: 00007ffead80b84f R14: 00007f4b20f9e9c0 R15: 000000000076bfd4

Allocated by task 9912:
 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 30364:
 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 ffff888065e1e000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1416 bytes inside of
 4096-byte region [ffff888065e1e000, ffff888065e1f000)
The buggy address belongs to the page:
page:ffffea0001978780 refcount:1 mapcount:0 mapping:ffff8880aa402000 index:0x0 compound_mapcount: 0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea0001978708 ffffea0001978d88 ffff8880aa402000
raw: 0000000000000000 ffff888065e1e000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888065e1e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888065e1e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888065e1e580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888065e1e600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888065e1e680: 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/16 10:51 upstream db70e26e33ee cf914200 .config console log report ci-upstream-kasan-gce-root
* Struck through repros no longer work on HEAD.