================================================================== BUG: KASAN: use-after-free in tls_write_space+0x156/0x180 net/tls/tls_main.c:219 Read of size 1 at addr ffff88808a201438 by task syz-executor.2/28898 CPU: 0 PID: 28898 Comm: syz-executor.2 Not tainted 5.1.0-rc5+ #70 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:187 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317 __asan_report_load1_noabort+0x14/0x20 mm/kasan/generic_report.c:129 tls_write_space+0x156/0x180 net/tls/tls_main.c:219 tcp_new_space net/ipv4/tcp_input.c:5125 [inline] tcp_check_space+0x435/0x730 net/ipv4/tcp_input.c:5136 tcp_data_snd_check net/ipv4/tcp_input.c:5146 [inline] tcp_rcv_established+0x996/0x1fb0 net/ipv4/tcp_input.c:5637 tcp_v4_do_rcv+0x616/0x8d0 net/ipv4/tcp_ipv4.c:1541 sk_backlog_rcv include/net/sock.h:943 [inline] __release_sock+0x12e/0x3a0 net/core/sock.c:2413 release_sock+0x59/0x1c0 net/core/sock.c:2929 tls_sk_proto_close+0x3f7/0x7a0 net/tls/tls_main.c:291 inet_release+0x105/0x1f0 net/ipv4/af_inet.c:428 __sock_release+0x1fe/0x2b0 net/socket.c:599 sock_release+0x18/0x20 net/socket.c:619 smc_release+0x55c/0x890 net/smc/af_smc.c:171 __sock_release+0xd3/0x2b0 net/socket.c:599 sock_close+0x1b/0x30 net/socket.c:1247 __fput+0x2e5/0x8d0 fs/file_table.c:278 ____fput+0x16/0x20 fs/file_table.c:309 task_work_run+0x14a/0x1c0 kernel/task_work.c:113 get_signal+0x1961/0x1d50 kernel/signal.c:2390 do_signal+0x87/0x1940 arch/x86/kernel/signal.c:816 exit_to_usermode_loop+0x244/0x2c0 arch/x86/entry/common.c:162 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_32_irqs_on arch/x86/entry/common.c:341 [inline] do_fast_syscall_32+0xa9d/0xc98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 RIP: 0023:0xf7f8c869 Code: 85 d2 74 02 89 0a 5b 5d c3 8b 04 24 c3 8b 14 24 c3 8b 3c 24 c3 90 90 90 90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 002b:00000000f5d880cc EFLAGS: 00000296 ORIG_RAX: 0000000000000004 RAX: 0000000000008000 RBX: 0000000000000004 RCX: 0000000020000040 RDX: 00000000ffffffc4 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 28898: save_stack+0x45/0xd0 mm/kasan/common.c:75 set_track mm/kasan/common.c:87 [inline] __kasan_kmalloc mm/kasan/common.c:497 [inline] __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:470 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:511 kmem_cache_alloc_trace+0x151/0x760 mm/slab.c:3623 kmalloc include/linux/slab.h:547 [inline] kzalloc include/linux/slab.h:742 [inline] create_ctx+0x46/0x1f0 net/tls/tls_main.c:575 tls_init net/tls/tls_main.c:761 [inline] tls_init+0x11f/0x510 net/tls/tls_main.c:743 __tcp_set_ulp net/ipv4/tcp_ulp.c:125 [inline] tcp_set_ulp+0x336/0x640 net/ipv4/tcp_ulp.c:146 do_tcp_setsockopt.isra.0+0x57a/0x23f0 net/ipv4/tcp.c:2805 tcp_setsockopt+0xc4/0xf0 net/ipv4/tcp.c:3119 sock_common_setsockopt+0x9a/0xe0 net/core/sock.c:3120 smc_setsockopt+0xd1/0x7d0 net/smc/af_smc.c:1683 __compat_sys_setsockopt+0x27c/0x380 net/compat.c:385 __do_compat_sys_setsockopt net/compat.c:395 [inline] __se_compat_sys_setsockopt net/compat.c:392 [inline] __ia32_compat_sys_setsockopt+0xbd/0x150 net/compat.c:392 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline] do_fast_syscall_32+0x281/0xc98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 Freed by task 28898: save_stack+0x45/0xd0 mm/kasan/common.c:75 set_track mm/kasan/common.c:87 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/common.c:459 kasan_slab_free+0xe/0x10 mm/kasan/common.c:467 __cache_free mm/slab.c:3500 [inline] kfree+0xcf/0x230 mm/slab.c:3823 tls_ctx_free.part.0+0x34/0x40 net/tls/tls_main.c:241 tls_ctx_free net/tls/tls_main.c:236 [inline] tls_sk_proto_close+0x3ea/0x7a0 net/tls/tls_main.c:286 inet_release+0x105/0x1f0 net/ipv4/af_inet.c:428 __sock_release+0x1fe/0x2b0 net/socket.c:599 sock_release+0x18/0x20 net/socket.c:619 smc_release+0x55c/0x890 net/smc/af_smc.c:171 __sock_release+0xd3/0x2b0 net/socket.c:599 sock_close+0x1b/0x30 net/socket.c:1247 __fput+0x2e5/0x8d0 fs/file_table.c:278 ____fput+0x16/0x20 fs/file_table.c:309 task_work_run+0x14a/0x1c0 kernel/task_work.c:113 get_signal+0x1961/0x1d50 kernel/signal.c:2390 do_signal+0x87/0x1940 arch/x86/kernel/signal.c:816 exit_to_usermode_loop+0x244/0x2c0 arch/x86/entry/common.c:162 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_32_irqs_on arch/x86/entry/common.c:341 [inline] do_fast_syscall_32+0xa9d/0xc98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 The buggy address belongs to the object at ffff88808a201340 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 248 bytes inside of 512-byte region [ffff88808a201340, ffff88808a201540) The buggy address belongs to the page: page:ffffea0002288040 count:1 mapcount:0 mapping:ffff88812c3f0940 index:0xffff88808a2015c0 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea0002576a88 ffffea0002516948 ffff88812c3f0940 raw: ffff88808a2015c0 ffff88808a2010c0 0000000100000004 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88808a201300: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ffff88808a201380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88808a201400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88808a201480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808a201500: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ==================================================================