syzbot


KASAN: use-after-free Read in ip6_route_me_harder

Status: fixed on 2018/03/06 13:29
Subsystems: netfilter
[Documentation on labels]
Fix commit: 7d98386d55a5 netfilter: use skb_to_full_sk in ip6_route_me_harder
First crash: 2250d, last: 2242d

Sample crash report:
IPv6: ADDRCONF(NETDEV_UP): bond0: link is not ready
8021q: adding VLAN 0 to HW filter on device bond0
IPv6: ADDRCONF(NETDEV_UP): veth0: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
==================================================================
BUG: KASAN: use-after-free in sock_net_uid include/net/sock.h:1732 [inline]
BUG: KASAN: use-after-free in ip6_route_me_harder+0x9d8/0xc00 net/ipv6/netfilter.c:26
Read of size 4 at addr ffff8801c20be1a8 by task syzkaller417947/4238

CPU: 0 PID: 4238 Comm: syzkaller417947 Not tainted 4.16.0-rc3+ #331
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23b/0x360 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 sock_net_uid include/net/sock.h:1732 [inline]
 ip6_route_me_harder+0x9d8/0xc00 net/ipv6/netfilter.c:26
 ip6t_mangle_out net/ipv6/netfilter/ip6table_mangle.c:63 [inline]
 ip6table_mangle_hook+0x636/0x920 net/ipv6/netfilter/ip6table_mangle.c:77
 nf_hook_entry_hookfn include/linux/netfilter.h:120 [inline]
 nf_hook_slow+0xba/0x1a0 net/netfilter/core.c:483
 nf_hook include/linux/netfilter.h:243 [inline]
 NF_HOOK include/linux/netfilter.h:286 [inline]
 ip6_xmit+0x10ec/0x2260 net/ipv6/ip6_output.c:277
 tcp_v6_send_synack+0x57b/0xaa0 net/ipv6/tcp_ipv6.c:490
 tcp_conn_request+0x26fd/0x3660 net/ipv4/tcp_input.c:6336
 tcp_v6_conn_request+0x212/0x270 net/ipv6/tcp_ipv6.c:1021
 tcp_rcv_state_process+0x8f5/0x4920 net/ipv4/tcp_input.c:5845
 tcp_v6_do_rcv+0x739/0x1250 net/ipv6/tcp_ipv6.c:1331
 tcp_v6_rcv+0x24a1/0x2d70 net/ipv6/tcp_ipv6.c:1510
 ip6_input_finish+0x37e/0x17a0 net/ipv6/ip6_input.c:284
 NF_HOOK include/linux/netfilter.h:288 [inline]
 ip6_input+0xdb/0x560 net/ipv6/ip6_input.c:327
 dst_input include/net/dst.h:449 [inline]
 ip6_rcv_finish+0x297/0x8c0 net/ipv6/ip6_input.c:71
 NF_HOOK include/linux/netfilter.h:288 [inline]
 ipv6_rcv+0xf38/0x1fb0 net/ipv6/ip6_input.c:208
 __netif_receive_skb_core+0x1a41/0x3460 net/core/dev.c:4554
 __netif_receive_skb+0x2c/0x1b0 net/core/dev.c:4619
 netif_receive_skb_internal+0x10b/0x670 net/core/dev.c:4693
 napi_frags_finish net/core/dev.c:5134 [inline]
 napi_gro_frags+0x58a/0xaf0 net/core/dev.c:5207
 tun_get_user+0x2720/0x3810 drivers/net/tun.c:1939
 tun_chr_write_iter+0xbd/0x1c0 drivers/net/tun.c:1984
 call_write_iter include/linux/fs.h:1781 [inline]
 do_iter_readv_writev+0x55c/0x830 fs/read_write.c:653
 do_iter_write+0x154/0x540 fs/read_write.c:932
 vfs_writev+0x18a/0x340 fs/read_write.c:977
 do_writev+0xfc/0x2a0 fs/read_write.c:1012
 SYSC_writev fs/read_write.c:1085 [inline]
 SyS_writev+0x27/0x30 fs/read_write.c:1082
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x443150
RSP: 002b:00007ffefe0bdad8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 000000000000001a RCX: 0000000000443150
RDX: 0000000000000001 RSI: 00007ffefe0bdaf0 RDI: 00000000000000fc
RBP: 00000000004a4a9b R08: 0000000000000013 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffefe0bdc10
R13: 00000000004042a0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 2886:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
 kmem_cache_alloc+0x12e/0x760 mm/slab.c:3541
 dup_mmap kernel/fork.c:451 [inline]
 dup_mm kernel/fork.c:1233 [inline]
 copy_mm+0x8d7/0x131f kernel/fork.c:1287
 copy_process.part.38+0x1f56/0x4b60 kernel/fork.c:1793
 copy_process kernel/fork.c:1606 [inline]
 _do_fork+0x1f7/0xf70 kernel/fork.c:2087
 SYSC_clone kernel/fork.c:2194 [inline]
 SyS_clone+0x37/0x50 kernel/fork.c:2188
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 3429:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
 __cache_free mm/slab.c:3485 [inline]
 kmem_cache_free+0x83/0x2a0 mm/slab.c:3743
 remove_vma+0x162/0x1b0 mm/mmap.c:176
 exit_mmap+0x311/0x500 mm/mmap.c:3049
 __mmput kernel/fork.c:960 [inline]
 mmput+0x223/0x6d0 kernel/fork.c:981
 exit_mm kernel/exit.c:544 [inline]
 do_exit+0x90a/0x1ad0 kernel/exit.c:852
 do_group_exit+0x149/0x400 kernel/exit.c:968
 SYSC_exit_group kernel/exit.c:979 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:977
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801c20be148
 which belongs to the cache vm_area_struct of size 200
The buggy address is located 96 bytes inside of
 200-byte region [ffff8801c20be148, ffff8801c20be210)
The buggy address belongs to the page:
page:ffffea0007082f80 count:1 mapcount:0 mapping:ffff8801c20be040 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801c20be040 0000000000000000 000000010000000f
raw: ffffea00071deb60 ffffea0007158820 ffff8801da5c3840 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801c20be080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801c20be100: fb fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb
>ffff8801c20be180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff8801c20be200: fb fb fc fc fc fc fc fc fc fc fb fb fb fb fb fb
 ffff8801c20be280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (44):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/02/27 16:52 upstream 6f70eb2b00eb 05b5a32c .config console log report syz C ci-upstream-kasan-gce
2018/02/27 11:49 net-next-old 3808b51911fe 05b5a32c .config console log report syz C ci-upstream-net-kasan-gce
2018/02/25 14:34 net-next-old f74290fdb363 5c1e0207 .config console log report syz C ci-upstream-net-kasan-gce
2018/03/05 11:34 net-next-old ca435f88c102 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/05 09:46 net-next-old ca435f88c102 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/05 04:44 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/05 04:43 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/05 02:39 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/05 02:07 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/05 00:45 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 23:17 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 20:14 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 19:31 net-next-old efab163bbc19 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 18:38 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 17:15 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 16:15 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 15:48 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 14:50 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 13:10 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 12:57 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 12:54 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 10:30 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 07:42 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 07:31 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 06:27 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 05:55 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 03:20 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 01:34 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 00:55 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/04 00:12 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 23:49 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 20:54 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 20:30 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 20:01 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 19:59 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 19:19 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 18:33 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 18:29 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/03 17:50 net-next-old e4e31cf07d0c 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/02 15:45 net-next-old 23e19fd4fb07 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/03/02 03:41 net-next-old f1c02cfb7b30 2c6f473e .config console log report ci-upstream-net-kasan-gce
2018/02/25 13:53 net-next-old f74290fdb363 5c1e0207 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.