================================================================== BUG: KASAN: use-after-free in tls_write_space+0x14b/0x170 net/tls/tls_main.c:239 Read of size 1 at addr ffff888098f0732a by task syz-executor.2/28404 CPU: 0 PID: 28404 Comm: syz-executor.2 Not tainted 5.2.0+ #67 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.cold+0x1b/0x36 mm/kasan/report.c:482 kasan_report+0x12/0x17 mm/kasan/common.c:612 __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+0x191/0x760 net/ipv4/tcp_input.c:5162 tcp_data_snd_check net/ipv4/tcp_input.c:5172 [inline] tcp_rcv_state_process+0xe24/0x4e3f net/ipv4/tcp_input.c:6303 tcp_v6_do_rcv+0x7d7/0x12c0 net/ipv6/tcp_ipv6.c:1381 tcp_v6_rcv+0x31f1/0x3500 net/ipv6/tcp_ipv6.c:1588 ip6_protocol_deliver_rcu+0x2fe/0x1660 net/ipv6/ip6_input.c:397 ip6_input_finish+0x84/0x170 net/ipv6/ip6_input.c:438 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip6_input+0xe4/0x3f0 net/ipv6/ip6_input.c:447 dst_input include/net/dst.h:442 [inline] ip6_rcv_finish+0x1de/0x2f0 net/ipv6/ip6_input.c:76 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ipv6_rcv+0x10e/0x420 net/ipv6/ip6_input.c:272 __netif_receive_skb_one_core+0x113/0x1a0 net/core/dev.c:4999 __netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5113 process_backlog+0x206/0x750 net/core/dev.c:5924 napi_poll net/core/dev.c:6347 [inline] net_rx_action+0x4d6/0x1030 net/core/dev.c:6413 __do_softirq+0x262/0x98c kernel/softirq.c:292 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0x19b/0x1e0 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:537 [inline] smp_apic_timer_interrupt+0x1a3/0x610 arch/x86/kernel/apic/apic.c:1095 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:828 RIP: 0010:debug_check_no_locks_held+0x0/0xa0 kernel/locking/lockdep.c:5245 Code: 17 8b 05 d3 ed 4c 08 85 c0 0f 84 fa e9 00 00 5b 41 5c 41 5d 41 5e 5d c3 48 c7 c7 b0 29 a5 89 e8 16 59 54 00 eb db 0f 1f 40 00 <48> b8 00 00 00 00 00 fc ff df 55 48 89 e5 41 55 41 54 53 65 48 8b RSP: 0018:ffff88806a997c80 EFLAGS: 00000293 ORIG_RAX: ffffffffffffff13 RAX: ffff888097862540 RBX: ffff88806a997dc0 RCX: ffffffff8738e207 RDX: 0000000000000000 RSI: ffffffff8738e4c0 RDI: 0000000000000005 RBP: ffff88806a997d68 R08: ffff888097862540 R09: ffffed1012f0c4a9 R10: ffffed1012f0c4a8 R11: ffff888097862547 R12: dffffc0000000000 R13: 0000000000000000 R14: ffff88806a997e00 R15: ffff888097862540 hrtimer_nanosleep+0x2a6/0x570 kernel/time/hrtimer.c:1733 __do_sys_nanosleep kernel/time/hrtimer.c:1767 [inline] __se_sys_nanosleep kernel/time/hrtimer.c:1754 [inline] __x64_sys_nanosleep+0x1a6/0x220 kernel/time/hrtimer.c:1754 do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x457cf1 Code: 75 14 b8 23 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 24 d3 fb ff c3 48 83 ec 08 e8 ea 46 00 00 48 89 04 24 b8 23 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 33 47 00 00 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007ffde94d5d80 EFLAGS: 00000293 ORIG_RAX: 0000000000000023 RAX: ffffffffffffffda RBX: 00000000001b2382 RCX: 0000000000457cf1 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007ffde94d5d90 RBP: 0000000000000001 R08: ffffffffffffffff R09: ffffffffffffffff R10: 00007ffde94d5e80 R11: 0000000000000293 R12: 000000000075bf20 R13: 000000000075c9a0 R14: 0000000000761198 R15: ffffffffffffffff Allocated by task 28427: save_stack+0x23/0x90 mm/kasan/common.c:69 set_track mm/kasan/common.c:77 [inline] __kasan_kmalloc mm/kasan/common.c:487 [inline] __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:460 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:501 kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3550 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:748 [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/0x24f0 net/ipv4/tcp.c:2808 tcp_setsockopt+0xbe/0xe0 net/ipv4/tcp.c:3135 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+0xfd/0x6a0 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 28425: 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:449 kasan_slab_free+0xe/0x10 mm/kasan/common.c:457 __cache_free mm/slab.c:3425 [inline] kfree+0x10a/0x2c0 mm/slab.c:3756 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+0xed/0x200 net/ipv4/af_inet.c:427 inet6_release+0x53/0x80 net/ipv6/af_inet6.c:470 __sock_release+0xce/0x280 net/socket.c:590 sock_close+0x1e/0x30 net/socket.c:1268 __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:188 [inline] exit_to_usermode_loop+0x316/0x380 arch/x86/entry/common.c:163 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] syscall_return_slowpath arch/x86/entry/common.c:274 [inline] do_syscall_64+0x5a9/0x6a0 arch/x86/entry/common.c:299 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff888098f072c0 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 106 bytes inside of 512-byte region [ffff888098f072c0, ffff888098f074c0) The buggy address belongs to the page: page:ffffea000263c1c0 refcount:1 mapcount:0 mapping:ffff8880aa400a80 index:0x0 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea00023159c8 ffffea0002363748 ffff8880aa400a80 raw: 0000000000000000 ffff888098f07040 0000000100000006 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888098f07200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888098f07280: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb >ffff888098f07300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888098f07380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888098f07400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================