syzbot


KASAN: use-after-free Read in erspan_build_header

Status: fixed on 2019/11/30 21:02
Reported-by: syzbot+c55520aef43a00617448@syzkaller.appspotmail.com
Fix commit: 1d629bf9b576 net: erspan: fix use-after-free
First crash: 1835d, last: 1800d
Fix bisection: fixed by (bisect log) :
commit 1d629bf9b5767cdbe902f32b058ae8c99df72516
Author: William Tu <u9012063@gmail.com>
Date: Wed Jan 24 01:01:29 2018 +0000

  net: erspan: fix use-after-free

  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in erspan_build_header net C 60 2269d 2278d 4/26 fixed on 2018/02/01 04:00

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): hsr_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): hsr0: link becomes ready
IPv6: ADDRCONF(NETDEV_UP): vxcan1: link is not ready
8021q: adding VLAN 0 to HW filter on device batadv0
==================================================================
BUG: KASAN: use-after-free in erspan_build_header+0x392/0x3b0 net/ipv4/ip_gre.c:706
Read of size 2 at addr ffff888095d8200b by task syz-executor200/7112

CPU: 0 PID: 7112 Comm: syz-executor200 Not tainted 4.14.113 #3
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+0x138/0x19c lib/dump_stack.c:53
 print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xaf/0x2b5 mm/kasan/report.c:393
 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:440
 erspan_build_header+0x392/0x3b0 net/ipv4/ip_gre.c:706
 erspan_xmit net/ipv4/ip_gre.c:748 [inline]
 erspan_xmit+0x3ec/0x11c0 net/ipv4/ip_gre.c:725
 __netdev_start_xmit include/linux/netdevice.h:4033 [inline]
 netdev_start_xmit include/linux/netdevice.h:4042 [inline]
 packet_direct_xmit+0x438/0x640 net/packet/af_packet.c:269
 packet_snd net/packet/af_packet.c:2969 [inline]
 packet_sendmsg+0x31e1/0x5990 net/packet/af_packet.c:2994
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xd0/0x110 net/socket.c:656
 ___sys_sendmsg+0x70c/0x850 net/socket.c:2062
 __sys_sendmsg+0xb9/0x140 net/socket.c:2096
 SYSC_sendmsg net/socket.c:2107 [inline]
 SyS_sendmsg+0x2d/0x50 net/socket.c:2103
 do_syscall_64+0x1eb/0x630 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x441f99
RSP: 002b:00007ffc8e56aec8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007ffc8e56aef0 RCX: 0000000000441f99
RDX: 0000000000000000 RSI: 0000000020000040 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000400 R09: 0000000000000400
R10: 0000000000000004 R11: 0000000000000246 R12: 00000000004a9b30
R13: 0000000000403510 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6389:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:489
 kmem_cache_alloc+0x12e/0x780 mm/slab.c:3552
 anon_vma_chain_alloc mm/rmap.c:129 [inline]
 anon_vma_clone+0xde/0x470 mm/rmap.c:269
 anon_vma_fork+0x87/0x4d0 mm/rmap.c:332
 dup_mmap kernel/fork.c:669 [inline]
 dup_mm kernel/fork.c:1199 [inline]
 copy_mm kernel/fork.c:1253 [inline]
 copy_process.part.0+0x45a0/0x6950 kernel/fork.c:1755
 copy_process kernel/fork.c:1570 [inline]
 _do_fork+0x19e/0xce0 kernel/fork.c:2058
 SYSC_clone kernel/fork.c:2168 [inline]
 SyS_clone+0x37/0x50 kernel/fork.c:2162
 do_syscall_64+0x1eb/0x630 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 6390:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kmem_cache_free+0x83/0x2b0 mm/slab.c:3758
 anon_vma_chain_free mm/rmap.c:134 [inline]
 unlink_anon_vmas+0x2a4/0x800 mm/rmap.c:401
 free_pgtables+0x183/0x2b0 mm/memory.c:643
 exit_mmap+0x294/0x4e0 mm/mmap.c:3058
 __mmput kernel/fork.c:926 [inline]
 mmput+0x114/0x440 kernel/fork.c:947
 exec_mmap fs/exec.c:1039 [inline]
 flush_old_exec+0x8c0/0x1b50 fs/exec.c:1271
 load_elf_binary+0x88e/0x4ba0 fs/binfmt_elf.c:855
 search_binary_handler fs/exec.c:1638 [inline]
 search_binary_handler+0x14f/0x700 fs/exec.c:1616
 exec_binprm fs/exec.c:1680 [inline]
 do_execveat_common.isra.0+0xffd/0x1dd0 fs/exec.c:1802
 do_execve fs/exec.c:1847 [inline]
 SYSC_execve fs/exec.c:1928 [inline]
 SyS_execve+0x39/0x50 fs/exec.c:1923
 do_syscall_64+0x1eb/0x630 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff888095d82000
 which belongs to the cache anon_vma_chain of size 80
The buggy address is located 11 bytes inside of
 80-byte region [ffff888095d82000, ffff888095d82050)
The buggy address belongs to the page:
page:ffffea0002576080 count:1 mapcount:0 mapping:ffff888095d82000 index:0x0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff888095d82000 0000000000000000 0000000100000024
raw: ffffea0002539d60 ffffea00024f49a0 ffff8880aa810940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888095d81f00: fb fb fb fb fb fb fc fc fc fc fb fb fb fb fb fb
 ffff888095d81f80: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888095d82000: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fb fb
                      ^
 ffff888095d82080: fb fb fb fb fb fb fb fb fc fc fc fc fb fb fb fb
 ffff888095d82100: fb fb fb fb fb fb fc fc fc fc fb fb fb fb fb fb
==================================================================

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/04/24 20:29 linux-4.14.y 68d7a45eec10 8e3c52b1 .config console log report syz C ci2-linux-4-14
2019/04/23 08:05 linux-4.14.y 68d7a45eec10 53199d6e .config console log report syz C ci2-linux-4-14
2019/04/11 13:11 linux-4.14.y 1ec8f1f0bffe e955ac50 .config console log report syz C ci2-linux-4-14
2019/04/11 13:00 linux-4.14.y 1ec8f1f0bffe e955ac50 .config console log report syz C ci2-linux-4-14
2019/05/15 17:29 linux-4.14.y 2af67d29b6fe bd4e3ac7 .config console log report ci2-linux-4-14
2019/05/03 12:07 linux-4.14.y 1c046f373132 1bfa09b9 .config console log report ci2-linux-4-14
2019/05/03 07:59 linux-4.14.y 1c046f373132 1bfa09b9 .config console log report ci2-linux-4-14
2019/04/25 05:33 linux-4.14.y 68d7a45eec10 8e3c52b1 .config console log report ci2-linux-4-14
2019/04/24 20:10 linux-4.14.y 68d7a45eec10 8e3c52b1 .config console log report ci2-linux-4-14
2019/04/21 20:52 linux-4.14.y 68d7a45eec10 b0e8efcb .config console log report ci2-linux-4-14
2019/04/19 14:25 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report ci2-linux-4-14
2019/04/19 07:33 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report ci2-linux-4-14
2019/04/18 03:28 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report ci2-linux-4-14
2019/04/18 03:22 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report ci2-linux-4-14
2019/04/18 03:22 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report ci2-linux-4-14
2019/04/18 03:20 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report ci2-linux-4-14
2019/04/12 15:49 linux-4.14.y 1ec8f1f0bffe 4f421599 .config console log report ci2-linux-4-14
2019/04/11 12:22 linux-4.14.y 1ec8f1f0bffe e955ac50 .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.