================================================================== BUG: KASAN: use-after-free in tls_write_space+0x14b/0x170 net/tls/tls_main.c:239 Read of size 1 at addr ffff8880932c056a by task syz-executor.5/18247 CPU: 1 PID: 18247 Comm: syz-executor.5 Not tainted 5.2.0-rc5-next-20190619 #18 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/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:5147 [inline] tcp_check_space+0x430/0x720 net/ipv4/tcp_input.c:5158 tcp_data_snd_check net/ipv4/tcp_input.c:5168 [inline] tcp_rcv_established+0x98f/0x1fa0 net/ipv4/tcp_input.c:5659 tcp_v6_do_rcv+0x41e/0x12c0 net/ipv6/tcp_ipv6.c:1351 tcp_v6_rcv+0x2c76/0x3570 net/ipv6/tcp_ipv6.c:1583 ip6_protocol_deliver_rcu+0x2fe/0x16c0 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:439 [inline] ip6_rcv_finish+0x1de/0x310 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:5009 __netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5123 process_backlog+0x206/0x750 net/core/dev.c:5934 napi_poll net/core/dev.c:6357 [inline] net_rx_action+0x4f5/0x1070 net/core/dev.c:6423 __do_softirq+0x25c/0x94c kernel/softirq.c:292 do_softirq_own_stack+0x2a/0x40 arch/x86/entry/entry_64.S:1040 do_softirq.part.0+0x11a/0x170 kernel/softirq.c:337 do_softirq kernel/softirq.c:329 [inline] __local_bh_enable_ip+0x211/0x270 kernel/softirq.c:189 __raw_spin_unlock_bh include/linux/spinlock_api_smp.h:176 [inline] _raw_spin_unlock_bh+0x31/0x40 kernel/locking/spinlock.c:207 spin_unlock_bh include/linux/spinlock.h:383 [inline] release_sock+0x156/0x1c0 net/core/sock.c:2945 tls_sk_proto_close+0x400/0x750 net/tls/tls_main.c:312 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:601 sock_close+0x1b/0x30 net/socket.c:1273 __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 get_signal+0x2007/0x2490 kernel/signal.c:2522 do_signal+0x87/0x1990 arch/x86/kernel/signal.c:815 exit_to_usermode_loop+0x244/0x2c0 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:279 [inline] do_syscall_64+0x58e/0x680 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4592c9 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:00007f441de28c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: 0000000000278000 RBX: 0000000000000006 RCX: 00000000004592c9 RDX: ffffffffffffffc1 RSI: 00000000200005c0 RDI: 0000000000000005 RBP: 000000000075c070 R08: 0000000000000000 R09: 1201000000003618 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f441de296d4 R13: 00000000004c707f R14: 00000000004dc260 R15: 00000000ffffffff Allocated by task 18252: 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:3540 kmalloc include/linux/slab.h:547 [inline] kzalloc include/linux/slab.h:743 [inline] create_ctx+0x46/0x1f0 net/tls/tls_main.c:601 tls_init net/tls/tls_main.c:787 [inline] tls_init+0x11d/0x510 net/tls/tls_main.c:769 __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+0x369/0x2430 net/ipv4/tcp.c:2804 tcp_setsockopt+0xbe/0xe0 net/ipv4/tcp.c:3132 sock_common_setsockopt+0x94/0xd0 net/core/sock.c:3130 __sys_setsockopt+0x17a/0x280 net/socket.c:2072 __do_sys_setsockopt net/socket.c:2083 [inline] __se_sys_setsockopt net/socket.c:2080 [inline] __x64_sys_setsockopt+0xbe/0x150 net/socket.c:2080 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 18247: 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:3417 [inline] kfree+0x10a/0x2c0 mm/slab.c:3746 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+0x3f3/0x750 net/tls/tls_main.c:307 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:601 sock_close+0x1b/0x30 net/socket.c:1273 __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 get_signal+0x2007/0x2490 kernel/signal.c:2522 do_signal+0x87/0x1990 arch/x86/kernel/signal.c:815 exit_to_usermode_loop+0x244/0x2c0 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: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 ffff8880932c0500 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 106 bytes inside of 512-byte region [ffff8880932c0500, ffff8880932c0700) The buggy address belongs to the page: page:ffffea00024cb000 refcount:1 mapcount:0 mapping:ffff8880aa400a80 index:0xffff8880932c0280 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea0002527148 ffffea0002860c08 ffff8880aa400a80 raw: ffff8880932c0280 ffff8880932c0000 0000000100000005 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880932c0400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880932c0480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8880932c0500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880932c0580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880932c0600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================