syzbot


KASAN: use-after-free Write in ip6_dst_destroy

Status: fixed on 2018/09/13 10:17
Subsystems: net
[Documentation on labels]
Fix commit: e873e4b9cc7e ipv6: use fib6_info_hold_safe() when necessary
First crash: 2119d, last: 2119d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:222 [inline]
BUG: KASAN: use-after-free in fib6_info_release include/net/ip6_fib.h:286 [inline]
BUG: KASAN: use-after-free in ip6_dst_destroy+0x2a4/0x4e0 net/ipv6/route.c:383
Write of size 4 at addr ffff8801d869a72c by task blkid/20858

CPU: 1 PID: 20858 Comm: blkid Not tainted 4.18.0-rc3+ #2
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+0x1c9/0x2b4 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 kasan_check_write+0x14/0x20 mm/kasan/kasan.c:278
 atomic_dec_and_test include/asm-generic/atomic-instrumented.h:222 [inline]
 fib6_info_release include/net/ip6_fib.h:286 [inline]
 ip6_dst_destroy+0x2a4/0x4e0 net/ipv6/route.c:383
 dst_destroy+0x118/0x3c0 net/core/dst.c:132
 dst_destroy_rcu+0x16/0x20 net/core/dst.c:154
 __rcu_reclaim kernel/rcu/rcu.h:178 [inline]
 rcu_do_batch kernel/rcu/tree.c:2558 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2818 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2785 [inline]
 rcu_process_callbacks+0xed5/0x1850 kernel/rcu/tree.c:2802
 __do_softirq+0x2e8/0xb17 kernel/softirq.c:288
 invoke_softirq kernel/softirq.c:368 [inline]
 irq_exit+0x1d1/0x200 kernel/softirq.c:408
 exiting_irq arch/x86/include/asm/apic.h:527 [inline]
 smp_apic_timer_interrupt+0x186/0x730 arch/x86/kernel/apic/apic.c:1052
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:863
 </IRQ>
RIP: 0010:preempt_count arch/x86/include/asm/preempt.h:23 [inline]
RIP: 0010:check_kcov_mode kernel/kcov.c:67 [inline]
RIP: 0010:__sanitizer_cov_trace_pc+0x11/0x50 kernel/kcov.c:101
Code: 7c 10 e0 4a 89 74 10 e8 4a 89 54 10 f0 4a 89 4c d8 20 4c 89 08 5d c3 66 90 55 65 48 8b 04 25 40 ee 01 00 65 8b 15 ef e1 85 7e <48> 89 e5 81 e2 00 01 1f 00 48 8b 75 08 75 2b 8b 90 90 12 00 00 83 
RSP: 0018:ffff880198347838 EFLAGS: 00000293 ORIG_RAX: ffffffffffffff13
RAX: ffff8801aed62140 RBX: ffff8801ad839080 RCX: ffffffff81c43500
RDX: 0000000080000000 RSI: ffffffff81c43514 RDI: ffff8801ad839080
RBP: ffff880198347860 R08: ffff8801aed62140 R09: ffffed0035b0721e
R10: ffffed0035b0721e R11: ffff8801ad8390f7 R12: 0000000000000001
R13: ffff8801ad839080 R14: ffff880198347c00 R15: dffffc0000000000
netlink: 'syz-executor2': attribute type 3 has an invalid length.
 put_filp+0x4c/0xb2 fs/file_table.c:306
 path_openat+0xc63/0x4e10 fs/namei.c:3552
netlink: 'syz-executor2': attribute type 3 has an invalid length.
 do_filp_open+0x255/0x380 fs/namei.c:3574
 do_sys_open+0x584/0x760 fs/open.c:1101
 __do_sys_openat fs/open.c:1128 [inline]
 __se_sys_openat fs/open.c:1122 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1122
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f23726fd1c8
Code: 00 00 48 83 ec 78 45 31 d2 f6 c2 40 48 89 4c 24 58 75 27 8b 05 35 a4 2b 00 85 c0 75 54 48 63 d2 48 63 ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 77 2e 48 83 c4 78 c3 0f 1f 00 48 8d 84 24 80 00 
RSP: 002b:00007ffe0e36c420 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007ffe0e36c9d0 RCX: 00007f23726fd1c8
RDX: 0000000000000000 RSI: 00007f23729d3ea0 RDI: 0000000000000004
RBP: 00007f23729d5064 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f23729d3ea0
R13: 0000000000000000 R14: 00007f2372bde820 R15: 00007f23729d42a2

Allocated by task 20749:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x780 mm/slab.c:3620
 kmalloc include/linux/slab.h:513 [inline]
 kzalloc include/linux/slab.h:707 [inline]
 fib6_info_alloc+0xc3/0x290 net/ipv6/ip6_fib.c:152
 ip6_route_info_create+0x7aa/0x2c30 net/ipv6/route.c:3010
 ip6_route_add+0x23/0xc0 net/ipv6/route.c:3151
 rt6_add_route_info+0x533/0x6f0 net/ipv6/route.c:3508
 rt6_route_rcv+0x625/0x880 net/ipv6/route.c:846
 ndisc_router_discovery+0x16e7/0x3370 net/ipv6/ndisc.c:1443
 ndisc_rcv+0x565/0x660 net/ipv6/ndisc.c:1751
 icmpv6_rcv+0x1456/0x1a60 net/ipv6/icmp.c:881
 ip6_input_finish+0x407/0x1a40 net/ipv6/ip6_input.c:284
 NF_HOOK include/linux/netfilter.h:287 [inline]
 ip6_input+0xe9/0x600 net/ipv6/ip6_input.c:327
 ip6_mc_input+0x45a/0xcf0 net/ipv6/ip6_input.c:404
 dst_input include/net/dst.h:450 [inline]
 ip6_rcv_finish+0x2ab/0xa30 net/ipv6/ip6_input.c:71
 NF_HOOK include/linux/netfilter.h:287 [inline]
 ipv6_rcv+0xec0/0x2060 net/ipv6/ip6_input.c:208
 __netif_receive_skb_core+0x2488/0x3680 net/core/dev.c:4628
 __netif_receive_skb+0x2c/0x1e0 net/core/dev.c:4693
 netif_receive_skb_internal+0x12e/0x7d0 net/core/dev.c:4767
 netif_receive_skb+0xbf/0x420 net/core/dev.c:4791
 tun_rx_batched.isra.55+0x4ba/0x8c0 drivers/net/tun.c:1571
 tun_get_user+0x2af1/0x42f0 drivers/net/tun.c:1981
 tun_chr_write_iter+0xb9/0x154 drivers/net/tun.c:2009
 call_write_iter include/linux/fs.h:1793 [inline]
 do_iter_readv_writev+0x897/0xa90 fs/read_write.c:680
 do_iter_write+0x185/0x5f0 fs/read_write.c:959
 vfs_writev+0x1f1/0x360 fs/read_write.c:1004
 do_writev+0x11a/0x310 fs/read_write.c:1039
 __do_sys_writev fs/read_write.c:1112 [inline]
 __se_sys_writev fs/read_write.c:1109 [inline]
 __x64_sys_writev+0x75/0xb0 fs/read_write.c:1109
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 20858:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xd9/0x260 mm/slab.c:3813
 fib6_info_destroy_rcu+0x2ab/0x360 net/ipv6/ip6_fib.c:208
 __rcu_reclaim kernel/rcu/rcu.h:178 [inline]
 rcu_do_batch kernel/rcu/tree.c:2558 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2818 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2785 [inline]
 rcu_process_callbacks+0xed5/0x1850 kernel/rcu/tree.c:2802
 __do_softirq+0x2e8/0xb17 kernel/softirq.c:288

The buggy address belongs to the object at ffff8801d869a700
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 44 bytes inside of
 256-byte region [ffff8801d869a700, ffff8801d869a800)
The buggy address belongs to the page:
page:ffffea000761a680 count:1 mapcount:0 mapping:ffff8801da8007c0 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0006e55b48 ffffea0006fad908 ffff8801da8007c0
raw: 0000000000000000 ffff8801d869a0c0 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d869a600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801d869a680: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801d869a700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff8801d869a780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d869a800: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/07/08 00:43 net-old 843789f6dd6a ab89aea9 .config console log report ci-upstream-net-this-kasan-gce
* Struck through repros no longer work on HEAD.