syzbot


KASAN: use-after-free Write in ip6_hold_safe

Status: fixed on 2018/08/28 17:48
Subsystems: net
[Documentation on labels]
Fix commit: 6d37fa49da1e l2tp: use sk_dst_check() to avoid race on sk->sk_dst_cache
First crash: 2094d, last: 2083d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __atomic_add_unless include/asm-generic/atomic-instrumented.h:89 [inline]
BUG: KASAN: use-after-free in atomic_add_unless include/linux/atomic.h:533 [inline]
BUG: KASAN: use-after-free in dst_hold_safe include/net/dst.h:308 [inline]
BUG: KASAN: use-after-free in ip6_hold_safe+0xbe/0x440 net/ipv6/route.c:1029
Write of size 4 at addr ffff8801ae370a80 by task syz-executor093/4766

CPU: 0 PID: 4766 Comm: syz-executor093 Not tainted 4.18.0-rc7+ #41
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+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_add_unless include/asm-generic/atomic-instrumented.h:89 [inline]
 atomic_add_unless include/linux/atomic.h:533 [inline]
 dst_hold_safe include/net/dst.h:308 [inline]
 ip6_hold_safe+0xbe/0x440 net/ipv6/route.c:1029
 rt6_get_pcpu_route net/ipv6/route.c:1249 [inline]
 ip6_pol_route+0x3ad/0x1250 net/ipv6/route.c:1922
 ip6_pol_route_output+0x54/0x70 net/ipv6/route.c:2098
 fib6_rule_lookup+0x26e/0x700 net/ipv6/fib6_rules.c:122
 ip6_route_output_flags+0x2c5/0x350 net/ipv6/route.c:2126
 ip6_dst_lookup_tail+0x1278/0x1da0 net/ipv6/ip6_output.c:978
 ip6_dst_lookup_flow+0xc8/0x270 net/ipv6/ip6_output.c:1079
 ip6_sk_dst_lookup_flow+0x5d2/0xac0 net/ipv6/ip6_output.c:1117
 udpv6_sendmsg+0x20f9/0x35f0 net/ipv6/udp.c:1357
 inet_sendmsg+0x1a1/0x690 net/ipv4/af_inet.c:798
 sock_sendmsg_nosec net/socket.c:642 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:652
 ___sys_sendmsg+0x51d/0x930 net/socket.c:2126
 __sys_sendmmsg+0x240/0x6f0 net/socket.c:2221
 __do_sys_sendmmsg net/socket.c:2250 [inline]
 __se_sys_sendmmsg net/socket.c:2247 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2247
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446a29
Code: e8 ac b8 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00 
RSP: 002b:00007f29b7885db8 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00000000006dcc38 RCX: 0000000000446a29
RDX: 00000000000000b8 RSI: 0000000020001b00 RDI: 0000000000000003
RBP: 00000000006dcc30 R08: 00007f29b7886700 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc3c
R13: 00007ffd015a2a4f R14: 00007f29b78869c0 R15: 0000000000000001

Allocated by task 4688:
 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
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc+0x12e/0x760 mm/slab.c:3554
 dst_alloc+0xbb/0x1d0 net/core/dst.c:105
 ip6_dst_alloc+0x35/0xa0 net/ipv6/route.c:353
 ip6_rt_pcpu_alloc net/ipv6/route.c:1229 [inline]
 rt6_make_pcpu_route net/ipv6/route.c:1259 [inline]
 ip6_pol_route+0x83f/0x1250 net/ipv6/route.c:1925
 ip6_pol_route_output+0x54/0x70 net/ipv6/route.c:2098
 fib6_rule_lookup+0x26e/0x700 net/ipv6/fib6_rules.c:122
 ip6_route_output_flags+0x2c5/0x350 net/ipv6/route.c:2126
 ip6_route_output include/net/ip6_route.h:88 [inline]
 ip6_dst_lookup_tail+0xe3f/0x1da0 net/ipv6/ip6_output.c:951
 ip6_dst_lookup_flow+0xc8/0x270 net/ipv6/ip6_output.c:1079
 ip6_datagram_dst_update+0x75b/0xf80 net/ipv6/datagram.c:91
 __ip6_datagram_connect+0x5fe/0x1470 net/ipv6/datagram.c:250
 ip6_datagram_connect+0x2f/0x50 net/ipv6/datagram.c:273
 inet_dgram_connect+0x154/0x2e0 net/ipv4/af_inet.c:571
 __sys_connect+0x37d/0x4c0 net/socket.c:1674
 __do_sys_connect net/socket.c:1685 [inline]
 __se_sys_connect net/socket.c:1682 [inline]
 __x64_sys_connect+0x73/0xb0 net/socket.c:1682
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4765:
 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]
 kmem_cache_free+0x86/0x2d0 mm/slab.c:3756
 dst_destroy+0x267/0x3c0 net/core/dst.c:141
 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:292

The buggy address belongs to the object at ffff8801ae370a40
 which belongs to the cache ip6_dst_cache of size 240
The buggy address is located 64 bytes inside of
 240-byte region [ffff8801ae370a40, ffff8801ae370b30)
The buggy address belongs to the page:
page:ffffea0006b8dc00 count:1 mapcount:0 mapping:ffff8801cde9c640 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea000754ef88 ffffea00073f20c8 ffff8801cde9c640
raw: 0000000000000000 ffff8801ae370040 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801ae370980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
 ffff8801ae370a00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8801ae370a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8801ae370b00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
 ffff8801ae370b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (25):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/08/04 01:35 net-old f664e37dcc52 df7f6947 .config console log report syz C ci-upstream-net-this-kasan-gce
2018/08/05 08:28 upstream 60f5a2173632 3476a2df .config console log report ci-upstream-kasan-gce-root
2018/08/03 22:46 upstream 0b5b1f9a78b5 df7f6947 .config console log report ci-upstream-kasan-gce-root
2018/08/03 21:00 upstream 0585df468e8f cc4f6d0a .config console log report ci-upstream-kasan-gce-root
2018/08/03 10:28 upstream 0585df468e8f cc4f6d0a .config console log report ci-upstream-kasan-gce-root
2018/08/03 05:55 upstream e30cb13c5a09 5b7e23bb .config console log report ci-upstream-kasan-gce-root
2018/08/03 05:21 upstream e30cb13c5a09 5b7e23bb .config console log report ci-upstream-kasan-gce-root
2018/08/03 02:47 upstream e30cb13c5a09 5b7e23bb .config console log report ci-upstream-kasan-gce-root
2018/08/02 23:09 upstream e30cb13c5a09 5b7e23bb .config console log report ci-upstream-kasan-gce-root
2018/08/01 05:33 upstream c1d61e7fe376 1477993e .config console log report ci-upstream-kasan-gce-root
2018/07/31 17:24 upstream c1d61e7fe376 1a381291 .config console log report ci-upstream-kasan-gce-root
2018/07/31 10:19 upstream 527838d470e3 1a381291 .config console log report ci-upstream-kasan-gce-root
2018/07/30 15:51 upstream acb1872577b3 1a381291 .config console log report ci-upstream-kasan-gce-root
2018/07/30 10:41 upstream acb1872577b3 1a381291 .config console log report ci-upstream-kasan-gce-root
2018/07/30 05:38 upstream 3cfb6772d4cf 1a381291 .config console log report ci-upstream-kasan-gce-root
2018/07/25 05:53 upstream 9981b4fb8684 375a3e31 .config console log report ci-upstream-kasan-gce
2018/08/04 12:13 net-old f664e37dcc52 df7f6947 .config console log report ci-upstream-net-this-kasan-gce
2018/08/03 09:07 net-old afb41bb03965 5b7e23bb .config console log report ci-upstream-net-this-kasan-gce
2018/08/03 08:21 net-old e30cb13c5a09 5b7e23bb .config console log report ci-upstream-net-this-kasan-gce
2018/08/01 21:22 net-old a94c689e6c9e 0a7cf4ec .config console log report ci-upstream-net-this-kasan-gce
2018/08/01 06:17 net-old 6751e7c66cb8 1477993e .config console log report ci-upstream-net-this-kasan-gce
2018/08/01 05:43 net-old 6751e7c66cb8 1477993e .config console log report ci-upstream-net-this-kasan-gce
2018/08/01 04:37 net-old 6751e7c66cb8 1477993e .config console log report ci-upstream-net-this-kasan-gce
2018/07/31 16:30 net-old 61f4b23769f0 1a381291 .config console log report ci-upstream-net-this-kasan-gce
2018/07/30 16:22 net-old 25432eba9cd8 1a381291 .config console log report ci-upstream-net-this-kasan-gce
* Struck through repros no longer work on HEAD.