KASAN: use-after-free Read in tcp_init_tso_segs

28 views
Skip to first unread message

syzbot

unread,
Sep 10, 2019, 7:25:07 AM9/10/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: e2cd24b6 Linux 4.14.143
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1551ee01600000
kernel config: https://syzkaller.appspot.com/x/.config?x=dcb6107bcdc0039
dashboard link: https://syzkaller.appspot.com/bug?extid=14330efdeec0df0b4c01
compiler: gcc (GCC) 9.0.0 20181231 (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+14330e...@syzkaller.appspotmail.com

kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x40000007
TCP: request_sock_TCPv6: Possible SYN flooding on port 20002. Sending
cookies. Check SNMP counters.
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x40000008
==================================================================
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x40000009
BUG: KASAN: use-after-free in tcp_skb_pcount include/net/tcp.h:911 [inline]
BUG: KASAN: use-after-free in tcp_init_tso_segs+0x1ae/0x200
net/ipv4/tcp_output.c:1790
Read of size 2 at addr ffff8880404d3d30 by task syz-executor.0/12781

CPU: 1 PID: 12781 Comm: syz-executor.0 Not tainted 4.14.143 #0
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/0x197 lib/dump_stack.c:53
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x4000000a
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+0xa9/0x2af mm/kasan/report.c:393
__asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
tcp_skb_pcount include/net/tcp.h:911 [inline]
tcp_init_tso_segs+0x1ae/0x200 net/ipv4/tcp_output.c:1790
tcp_write_xmit+0x15e/0x4960 net/ipv4/tcp_output.c:2330
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x4000000b
__tcp_push_pending_frames+0xa6/0x260 net/ipv4/tcp_output.c:2563
tcp_send_fin+0x17e/0xc40 net/ipv4/tcp_output.c:3115
tcp_close+0xcc8/0xfb0 net/ipv4/tcp.c:2221
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x4000000c
tls_sk_proto_close+0x157/0x750 net/tls/tls_main.c:295
inet_release+0xec/0x1c0 net/ipv4/af_inet.c:425
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x4000000d
inet6_release+0x53/0x80 net/ipv6/af_inet6.c:450
__sock_release+0xce/0x2b0 net/socket.c:602
sock_close+0x1b/0x30 net/socket.c:1139
__fput+0x275/0x7a0 fs/file_table.c:210
____fput+0x16/0x20 fs/file_table.c:244
task_work_run+0x114/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1da/0x220 arch/x86/entry/common.c:164
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
do_syscall_64+0x4bc/0x640 arch/x86/entry/common.c:297
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x4135d1
RSP: 002b:00007ffcc546c3c0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00000000004135d1
RDX: 0000001b32520000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000001 R08: 000000006e783fbb R09: 000000006e783fbf
R10: 00007ffcc546c4a0 R11: 0000000000000293 R12: 000000000075bf20
R13: 000000000004bcae R14: 0000000000760628 R15: ffffffffffffffff

Allocated by task 12785:
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_node+0x144/0x780 mm/slab.c:3642
kvm [12758]: vcpu0, guest rIP: 0xc5 Hyper-V unhandled rdmsr: 0x4000000e
__alloc_skb+0x9c/0x500 net/core/skbuff.c:193
alloc_skb_fclone include/linux/skbuff.h:1022 [inline]
sk_stream_alloc_skb+0xb3/0x780 net/ipv4/tcp.c:855
tcp_sendmsg_locked+0xf61/0x3200 net/ipv4/tcp.c:1301
tcp_sendmsg+0x30/0x50 net/ipv4/tcp.c:1457
inet_sendmsg+0x122/0x500 net/ipv4/af_inet.c:762
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xce/0x110 net/socket.c:656
SYSC_sendto+0x206/0x310 net/socket.c:1763
SyS_sendto+0x40/0x50 net/socket.c:1731
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 12785:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
kvm [12758]: vcpu0, guest rIP: 0xcc Hyper-V uhandled wrmsr: 0x40000020 data
0x282e40
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
kfree_skbmem+0x8d/0x120 net/core/skbuff.c:607
__kfree_skb+0x1e/0x30 net/core/skbuff.c:646
sk_wmem_free_skb include/net/sock.h:1416 [inline]
tcp_remove_empty_skb.part.0+0x231/0x2e0 net/ipv4/tcp.c:929
tcp_remove_empty_skb net/ipv4/tcp.c:925 [inline]
tcp_sendmsg_locked+0x1ced/0x3200 net/ipv4/tcp.c:1435
tcp_sendmsg+0x30/0x50 net/ipv4/tcp.c:1457
inet_sendmsg+0x122/0x500 net/ipv4/af_inet.c:762
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xce/0x110 net/socket.c:656
kobject: 'kvm' (ffff8880a6e282d0): kobject_uevent_env
SYSC_sendto+0x206/0x310 net/socket.c:1763
kobject: 'kvm' (ffff8880a6e282d0): fill_kobj_path: path
= '/devices/virtual/misc/kvm'
SyS_sendto+0x40/0x50 net/socket.c:1731
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8880404d3d00
which belongs to the cache skbuff_fclone_cache of size 472
The buggy address is located 48 bytes inside of
472-byte region [ffff8880404d3d00, ffff8880404d3ed8)
The buggy address belongs to the page:
page:ffffea00010134c0 count:1 mapcount:0 mapping:ffff8880404d3080 index:0x0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff8880404d3080 0000000000000000 0000000100000006
raw: ffffea000231cea0 ffffea000130c320 ffff88821b7203c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880404d3c00: fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc
ffff8880404d3c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8880404d3d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880404d3d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880404d3e00: 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 syzk...@googlegroups.com.

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

syzbot

unread,
Sep 10, 2019, 10:02:08 AM9/10/19
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: e2cd24b6 Linux 4.14.143
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15c52cf6600000
kernel config: https://syzkaller.appspot.com/x/.config?x=dcb6107bcdc0039
dashboard link: https://syzkaller.appspot.com/bug?extid=14330efdeec0df0b4c01
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12a6fdc1600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15ec9799600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+14330e...@syzkaller.appspotmail.com

audit: type=1400 audit(1568123905.380:36): avc: denied { map } for
pid=6868 comm="syz-executor314" path="/root/syz-executor314626549"
dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
TCP: request_sock_TCPv6: Possible SYN flooding on port 20002. Sending
cookies. Check SNMP counters.
==================================================================
BUG: KASAN: use-after-free in tcp_skb_pcount include/net/tcp.h:911 [inline]
BUG: KASAN: use-after-free in tcp_init_tso_segs+0x1ae/0x200
net/ipv4/tcp_output.c:1790
Read of size 2 at addr ffff88809973e330 by task syz-executor314/6868

CPU: 0 PID: 6868 Comm: syz-executor314 Not tainted 4.14.143 #0
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/0x197 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+0xa9/0x2af mm/kasan/report.c:393
__asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
tcp_skb_pcount include/net/tcp.h:911 [inline]
tcp_init_tso_segs+0x1ae/0x200 net/ipv4/tcp_output.c:1790
tcp_write_xmit+0x15e/0x4960 net/ipv4/tcp_output.c:2330
__tcp_push_pending_frames+0xa6/0x260 net/ipv4/tcp_output.c:2563
tcp_send_fin+0x17e/0xc40 net/ipv4/tcp_output.c:3115
tcp_close+0xcc8/0xfb0 net/ipv4/tcp.c:2221
inet_release+0xec/0x1c0 net/ipv4/af_inet.c:425
inet6_release+0x53/0x80 net/ipv6/af_inet6.c:450
__sock_release+0xce/0x2b0 net/socket.c:602
sock_close+0x1b/0x30 net/socket.c:1139
__fput+0x275/0x7a0 fs/file_table.c:210
____fput+0x16/0x20 fs/file_table.c:244
task_work_run+0x114/0x190 kernel/task_work.c:113
exit_task_work include/linux/task_work.h:22 [inline]
do_exit+0x7df/0x2c10 kernel/exit.c:874
do_group_exit+0x111/0x330 kernel/exit.c:977
SYSC_exit_group kernel/exit.c:988 [inline]
SyS_exit_group+0x1d/0x20 kernel/exit.c:986
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43ee88
RSP: 002b:00007fffb7781088 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043ee88
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004be688 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 0000000020040010 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d0180 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6868:
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_node+0x144/0x780 mm/slab.c:3642
__alloc_skb+0x9c/0x500 net/core/skbuff.c:193
alloc_skb_fclone include/linux/skbuff.h:1022 [inline]
sk_stream_alloc_skb+0xb3/0x780 net/ipv4/tcp.c:855
tcp_sendmsg_locked+0xf61/0x3200 net/ipv4/tcp.c:1301
tcp_sendmsg+0x30/0x50 net/ipv4/tcp.c:1457
inet_sendmsg+0x122/0x500 net/ipv4/af_inet.c:762
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xce/0x110 net/socket.c:656
SYSC_sendto+0x206/0x310 net/socket.c:1763
SyS_sendto+0x40/0x50 net/socket.c:1731
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 6868:
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
kfree_skbmem+0x8d/0x120 net/core/skbuff.c:607
__kfree_skb+0x1e/0x30 net/core/skbuff.c:646
sk_wmem_free_skb include/net/sock.h:1416 [inline]
tcp_remove_empty_skb.part.0+0x231/0x2e0 net/ipv4/tcp.c:929
tcp_remove_empty_skb net/ipv4/tcp.c:925 [inline]
tcp_sendmsg_locked+0x1ced/0x3200 net/ipv4/tcp.c:1435
tcp_sendmsg+0x30/0x50 net/ipv4/tcp.c:1457
inet_sendmsg+0x122/0x500 net/ipv4/af_inet.c:762
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xce/0x110 net/socket.c:656
SYSC_sendto+0x206/0x310 net/socket.c:1763
SyS_sendto+0x40/0x50 net/socket.c:1731
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff88809973e300
which belongs to the cache skbuff_fclone_cache of size 472
The buggy address is located 48 bytes inside of
472-byte region [ffff88809973e300, ffff88809973e4d8)
The buggy address belongs to the page:
page:ffffea000265cf80 count:1 mapcount:0 mapping:ffff88809973e080 index:0x0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff88809973e080 0000000000000000 0000000100000006
raw: ffffea00029315e0 ffffea0002574520 ffff88821b75f3c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809973e200: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
ffff88809973e280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff88809973e300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809973e380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809973e400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Eric Biggers

unread,
Oct 3, 2019, 9:56:20 PM10/3/19
to syzbot, syzkaller...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-lts-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-lts-b...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-lts-bugs/000000000000911dd605923359b5%40google.com.

#syz fix: tcp: Reset send_head when removing skb from write-queue
Reply all
Reply to author
Forward
0 new messages