================================================================== BUG: KASAN: use-after-free in tls_write_space+0x14b/0x170 net/tls/tls_main.c:239 Read of size 1 at addr ffff88809ecd1d2a by task syz-executor.3/10759 CPU: 0 PID: 10759 Comm: syz-executor.3 Not tainted 5.2.0-rc6+ #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+0x7c/0x20d mm/kasan/report.c:188 __kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317 kasan_report+0x12/0x20 mm/kasan/common.c:614 __asan_report_load1_noabort+0x14/0x20 mm/kasan/generic_report.c:129 tls_write_space+0x14b/0x170 net/tls/tls_main.c:239 tcp_new_space net/ipv4/tcp_input.c:5151 [inline] tcp_check_space+0x430/0x720 net/ipv4/tcp_input.c:5162 tcp_data_snd_check net/ipv4/tcp_input.c:5172 [inline] tcp_rcv_established+0x98f/0x1fa0 net/ipv4/tcp_input.c:5663 tcp_v6_do_rcv+0x41e/0x12c0 net/ipv6/tcp_ipv6.c:1351 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 tls_sk_proto_close+0x282/0x6b0 net/tls/tls_main.c:313 inet_release+0xe0/0x1f0 net/ipv4/af_inet.c:427 inet6_release+0x53/0x80 net/ipv6/af_inet6.c:470 __sock_release+0xce/0x2a0 net/socket.c:594 sock_close+0x1b/0x30 net/socket.c:1272 __fput+0x2ff/0x890 fs/file_table.c:280 ____fput+0x16/0x20 fs/file_table.c:313 task_work_run+0x145/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:168 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline] syscall_return_slowpath arch/x86/entry/common.c:279 [inline] do_syscall_64+0x58e/0x680 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4134b1 Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007ffdf4f539e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000005 RCX: 00000000004134b1 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004 RBP: 0000000000000001 R08: ffffffff8128601c R09: 00000000282c5dd7 R10: 00007ffdf4f53ac0 R11: 0000000000000293 R12: 000000000075c9a0 R13: 000000000075c9a0 R14: 0000000000761920 R15: ffffffffffffffff Allocated by task 10760: save_stack+0x23/0x90 mm/kasan/common.c:71 set_track mm/kasan/common.c:79 [inline] __kasan_kmalloc mm/kasan/common.c:489 [inline] __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503 kmem_cache_alloc_trace+0x151/0x750 mm/slab.c:3555 kmalloc include/linux/slab.h:547 [inline] kzalloc include/linux/slab.h:742 [inline] create_ctx+0x46/0x1f0 net/tls/tls_main.c:602 tls_init net/tls/tls_main.c:788 [inline] tls_init+0x11d/0x510 net/tls/tls_main.c:770 __tcp_set_ulp net/ipv4/tcp_ulp.c:126 [inline] tcp_set_ulp+0x330/0x640 net/ipv4/tcp_ulp.c:147 do_tcp_setsockopt.isra.0+0x363/0x2430 net/ipv4/tcp.c:2804 tcp_setsockopt+0xbe/0xe0 net/ipv4/tcp.c:3131 sock_common_setsockopt+0x94/0xd0 net/core/sock.c:3130 __sys_setsockopt+0x253/0x4b0 net/socket.c:2089 __do_sys_setsockopt net/socket.c:2105 [inline] __se_sys_setsockopt net/socket.c:2102 [inline] __x64_sys_setsockopt+0xbe/0x150 net/socket.c:2102 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 10759: save_stack+0x23/0x90 mm/kasan/common.c:71 set_track mm/kasan/common.c:79 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/common.c:451 kasan_slab_free+0xe/0x10 mm/kasan/common.c:459 __cache_free mm/slab.c:3432 [inline] kfree+0xcf/0x220 mm/slab.c:3755 tls_ctx_free.part.0+0x3a/0x40 net/tls/tls_main.c:261 tls_ctx_free net/tls/tls_main.c:256 [inline] tls_sk_proto_close+0x275/0x6b0 net/tls/tls_main.c:308 inet_release+0xe0/0x1f0 net/ipv4/af_inet.c:427 inet6_release+0x53/0x80 net/ipv6/af_inet6.c:470 __sock_release+0xce/0x2a0 net/socket.c:594 sock_close+0x1b/0x30 net/socket.c:1272 __fput+0x2ff/0x890 fs/file_table.c:280 ____fput+0x16/0x20 fs/file_table.c:313 task_work_run+0x145/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:168 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline] syscall_return_slowpath arch/x86/entry/common.c:279 [inline] do_syscall_64+0x58e/0x680 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff88809ecd1cc0 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 106 bytes inside of 512-byte region [ffff88809ecd1cc0, ffff88809ecd1ec0) The buggy address belongs to the page: page:ffffea00027b3440 refcount:1 mapcount:0 mapping:ffff8880aa400940 index:0x0 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea00027f4b08 ffffea000297ca08 ffff8880aa400940 raw: 0000000000000000 ffff88809ecd1040 0000000100000006 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809ecd1c00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88809ecd1c80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb >ffff88809ecd1d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809ecd1d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809ecd1e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================