syzbot


KASAN: invalid-free in tls_sk_proto_cleanup

Status: fixed on 2019/08/27 17:15
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+f5731e2256eb5130dbd6@syzkaller.appspotmail.com
Fix commit: 5d92e631b8be net/tls: partially revert fix transition through disconnect with close
First crash: 1728d, last: 1720d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: invalid-free in tls_sk_proto_cleanup 1 (2) 2019/07/31 22:46

Sample crash report:
==================================================================
BUG: KASAN: double-free or invalid-free in tls_sk_proto_cleanup+0x216/0x3e0 net/tls/tls_main.c:300

CPU: 0 PID: 18609 Comm: syz-executor.1 Not tainted 5.3.0-rc2-next-20190802 #58
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0xd4/0x306 mm/kasan/report.c:351
 kasan_report_invalid_free+0x65/0xa0 mm/kasan/report.c:444
 __kasan_slab_free+0x13a/0x150 mm/kasan/common.c:427
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:456
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 tls_sk_proto_cleanup+0x216/0x3e0 net/tls/tls_main.c:300
 tls_sk_proto_unhash+0x90/0x3f0 net/tls/tls_main.c:330
 tcp_set_state+0x5b9/0x7d0 net/ipv4/tcp.c:2235
 tcp_done+0xe2/0x320 net/ipv4/tcp.c:3824
 tcp_reset+0x132/0x500 net/ipv4/tcp_input.c:4123
 tcp_validate_incoming+0xa2d/0x1660 net/ipv4/tcp_input.c:5483
 tcp_rcv_established+0x6b5/0x1e70 net/ipv4/tcp_input.c:5691
 tcp_v6_do_rcv+0x41e/0x12c0 net/ipv6/tcp_ipv6.c:1371
 sk_backlog_rcv include/net/sock.h:945 [inline]
 __release_sock+0x129/0x390 net/core/sock.c:2418
 release_sock+0x59/0x1c0 net/core/sock.c:2934
 sk_stream_wait_memory+0x65a/0xfc0 net/core/stream.c:149
 tls_sw_sendmsg+0x673/0x17b0 net/tls/tls_sw.c:1054
 inet6_sendmsg+0x9e/0xe0 net/ipv6/af_inet6.c:576
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 __sys_sendto+0x262/0x380 net/socket.c:1952
 __do_sys_sendto net/socket.c:1964 [inline]
 __se_sys_sendto net/socket.c:1960 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1960
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459829
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fe94aa15c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 0000000000459829
RDX: ffffffffffffffc1 RSI: 00000000200005c0 RDI: 0000000000000004
RBP: 000000000075bf20 R08: 0000000000000000 R09: 1201000000003618
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe94aa166d4
R13: 00000000004c77d9 R14: 00000000004dcf90 R15: 00000000ffffffff

Allocated by task 18609:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:486 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:459
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:500
 __do_kmalloc mm/slab.c:3655 [inline]
 __kmalloc_track_caller+0x15f/0x760 mm/slab.c:3670
 kmemdup+0x27/0x60 mm/util.c:127
 kmemdup include/linux/string.h:477 [inline]
 tls_set_sw_offload+0xb3a/0x1567 net/tls/tls_sw.c:2361
 do_tls_setsockopt_conf net/tls/tls_main.c:581 [inline]
 do_tls_setsockopt net/tls/tls_main.c:630 [inline]
 tls_setsockopt+0x4d5/0x8d0 net/tls/tls_main.c:649
 sock_common_setsockopt+0x94/0xd0 net/core/sock.c:3130
 __sys_setsockopt+0x261/0x4c0 net/socket.c:2084
 __do_sys_setsockopt net/socket.c:2100 [inline]
 __se_sys_setsockopt net/socket.c:2097 [inline]
 __x64_sys_setsockopt+0xbe/0x150 net/socket.c:2097
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 18609:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:448
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:456
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 tls_sk_proto_cleanup+0x216/0x3e0 net/tls/tls_main.c:300
 tls_sk_proto_unhash+0x90/0x3f0 net/tls/tls_main.c:330
 tcp_set_state+0x5b9/0x7d0 net/ipv4/tcp.c:2235
 tcp_done+0xe2/0x320 net/ipv4/tcp.c:3824
 tcp_reset+0x132/0x500 net/ipv4/tcp_input.c:4123
 tcp_validate_incoming+0xa2d/0x1660 net/ipv4/tcp_input.c:5483
 tcp_rcv_established+0x6b5/0x1e70 net/ipv4/tcp_input.c:5691
 tcp_v6_do_rcv+0x41e/0x12c0 net/ipv6/tcp_ipv6.c:1371
 sk_backlog_rcv include/net/sock.h:945 [inline]
 __release_sock+0x129/0x390 net/core/sock.c:2418
 release_sock+0x59/0x1c0 net/core/sock.c:2934
 wait_on_pending_writer+0x20f/0x420 net/tls/tls_main.c:91
 tls_sk_proto_cleanup+0x2c5/0x3e0 net/tls/tls_main.c:295
 tls_sk_proto_unhash+0x90/0x3f0 net/tls/tls_main.c:330
 tcp_set_state+0x5b9/0x7d0 net/ipv4/tcp.c:2235
 tcp_done+0xe2/0x320 net/ipv4/tcp.c:3824
 tcp_reset+0x132/0x500 net/ipv4/tcp_input.c:4123
 tcp_validate_incoming+0xa2d/0x1660 net/ipv4/tcp_input.c:5483
 tcp_rcv_established+0x6b5/0x1e70 net/ipv4/tcp_input.c:5691
 tcp_v6_do_rcv+0x41e/0x12c0 net/ipv6/tcp_ipv6.c:1371
 sk_backlog_rcv include/net/sock.h:945 [inline]
 __release_sock+0x129/0x390 net/core/sock.c:2418
 release_sock+0x59/0x1c0 net/core/sock.c:2934
 sk_stream_wait_memory+0x65a/0xfc0 net/core/stream.c:149
 tls_sw_sendmsg+0x673/0x17b0 net/tls/tls_sw.c:1054
 inet6_sendmsg+0x9e/0xe0 net/ipv6/af_inet6.c:576
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 __sys_sendto+0x262/0x380 net/socket.c:1952
 __do_sys_sendto net/socket.c:1964 [inline]
 __se_sys_sendto net/socket.c:1960 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1960
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888099597b40
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff888099597b40, ffff888099597b60)
The buggy address belongs to the page:
page:ffffea00026565c0 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff888099597fc1
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00028535c8 ffffea00026d2f88 ffff8880aa4001c0
raw: ffff888099597fc1 ffff888099597000 000000010000002f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888099597a00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff888099597a80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>ffff888099597b00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
                                           ^
 ffff888099597b80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff888099597c00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/08/03 08:26 linux-next 7b4980e0bcf4 6affd8e8 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/08/01 22:38 linux-next 882e8691130b 835dffe7 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/07/29 08:07 linux-next fde50b96be82 c85e1c5b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/07/27 13:40 linux-next fde50b96be82 c85e1c5b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/07/26 22:58 linux-next fde50b96be82 3e5d1beb .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.