KASAN: use-after-free Read in ip6_tnl_parse_tlv_enc_lim

From: syzbot
Date: Thu Nov 01 2018 - 12:51:09 EST


Hello,

syzbot found the following crash on:

HEAD commit: 44adbac8f721 Merge branch 'work.tty-ioctl' of git://git.ke..
git tree: bpf-next
console output: https://syzkaller.appspot.com/x/log.txt?x=16043183400000
kernel config: https://syzkaller.appspot.com/x/.config?x=9cb981ee01463dea
dashboard link: https://syzkaller.appspot.com/bug?extid=2c8d8fccd6cece4ede2a
compiler: gcc (GCC) 8.0.1 20180413 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+2c8d8fccd6cece4ede2a@xxxxxxxxxxxxxxxxxxxxxxxxx

ïï6ïïaï~IyMïï: renamed from nr0
==================================================================
BUG: KASAN: use-after-free in ip6_tnl_parse_tlv_enc_lim+0x5df/0x660 net/ipv6/ip6_tunnel.c:417
Read of size 1 at addr ffff8801ca21227f by task syz-executor0/11239

CPU: 1 PID: 11239 Comm: syz-executor0 Not tainted 4.19.0+ #135
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+0x244/0x39d lib/dump_stack.c:113
print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
__asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430
ip6_tnl_parse_tlv_enc_lim+0x5df/0x660 net/ipv6/ip6_tunnel.c:417
ip6ip6_tnl_xmit net/ipv6/ip6_tunnel.c:1348 [inline]
ip6_tnl_start_xmit+0x49f/0x25a0 net/ipv6/ip6_tunnel.c:1412
__netdev_start_xmit include/linux/netdevice.h:4336 [inline]
netdev_start_xmit include/linux/netdevice.h:4345 [inline]
xmit_one net/core/dev.c:3252 [inline]
dev_hard_start_xmit+0x295/0xc90 net/core/dev.c:3268
__dev_queue_xmit+0x2f71/0x3ad0 net/core/dev.c:3838
dev_queue_xmit+0x17/0x20 net/core/dev.c:3871
__bpf_tx_skb net/core/filter.c:2017 [inline]
__bpf_redirect_common net/core/filter.c:2055 [inline]
__bpf_redirect+0x5cf/0xb20 net/core/filter.c:2062
____bpf_clone_redirect net/core/filter.c:2095 [inline]
bpf_clone_redirect+0x2f6/0x490 net/core/filter.c:2067
bpf_prog_759a992c578a3894+0x7d7/0x1000

Allocated by task 10771:
save_stack+0x43/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:490
kmem_cache_alloc+0x12e/0x730 mm/slab.c:3554
getname_flags+0xd0/0x5a0 fs/namei.c:140
getname fs/namei.c:211 [inline]
user_path_create fs/namei.c:3693 [inline]
do_symlinkat+0xe9/0x2d0 fs/namei.c:4147
__do_sys_symlink fs/namei.c:4173 [inline]
__se_sys_symlink fs/namei.c:4171 [inline]
__x64_sys_symlink+0x59/0x80 fs/namei.c:4171
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 10771:
save_stack+0x43/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
__kasan_slab_free+0x102/0x150 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+0x83/0x290 mm/slab.c:3756
putname+0xf2/0x130 fs/namei.c:261
filename_create+0x2b2/0x5b0 fs/namei.c:3658
user_path_create fs/namei.c:3693 [inline]
do_symlinkat+0xfe/0x2d0 fs/namei.c:4147
__do_sys_symlink fs/namei.c:4173 [inline]
__se_sys_symlink fs/namei.c:4171 [inline]
__x64_sys_symlink+0x59/0x80 fs/namei.c:4171
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801ca212140
which belongs to the cache names_cache of size 4096
The buggy address is located 319 bytes inside of
4096-byte region [ffff8801ca212140, ffff8801ca213140)
The buggy address belongs to the page:
page:ffffea0007288480 count:1 mapcount:0 mapping:ffff8801da973d80 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffffea0006dd6288 ffffea0007223988 ffff8801da973d80
raw: 0000000000000000 ffff8801ca212140 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801ca212100: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff8801ca212180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801ca212200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801ca212280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801ca212300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with syzbot.