KASAN: use-after-free Read in selinux_socket_connect

8 views
Skip to first unread message

syzbot

unread,
Apr 14, 2019, 4:51:33 AM4/14/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 38f41ec1 Merge 4.4.125 into android-4.4
git tree: android-4.4
console output: https://syzkaller.appspot.com/x/log.txt?x=14bf5ed3800000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3227609e1874daa
dashboard link: https://syzkaller.appspot.com/bug?extid=04274e82acde9079c8b6
compiler: gcc (GCC) 7.1.1 20170620
userspace arch: i386
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=160980db800000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+04274e...@syzkaller.appspotmail.com

random: nonblocking pool is initialized
l2tp_core: tunl 4: sockfd_lookup(fd=3) returned -9
==================================================================
BUG: KASAN: use-after-free in selinux_socket_connect+0x489/0x490
security/selinux/hooks.c:4244
Read of size 8 at addr ffff8801d89b58f8 by task syz-executor5/15720

CPU: 1 PID: 15720 Comm: syz-executor5 Not tainted 4.4.125-g38f41ec #21
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
0000000000000000 aba813925c4a146d ffff8801c87dfad8 ffffffff81d067bd
ffffea0007626c00 ffff8801d89b58f8 0000000000000000 ffff8801d89b58f8
ffff8801c87dfdc0 ffff8801c87dfb10 ffffffff814fea83 ffff8801d89b58f8
Call Trace:
[<ffffffff81d067bd>] __dump_stack lib/dump_stack.c:15 [inline]
[<ffffffff81d067bd>] dump_stack+0xc1/0x124 lib/dump_stack.c:51
[<ffffffff814fea83>] print_address_description+0x73/0x260
mm/kasan/report.c:252
[<ffffffff814fef95>] kasan_report_error mm/kasan/report.c:351 [inline]
[<ffffffff814fef95>] kasan_report+0x285/0x370 mm/kasan/report.c:408
[<ffffffff814ff0f4>] __asan_report_load8_noabort+0x14/0x20
mm/kasan/report.c:429
[<ffffffff81b6b8f9>] selinux_socket_connect+0x489/0x490
security/selinux/hooks.c:4244
[<ffffffff81b4946d>] security_socket_connect+0x7d/0xb0
security/security.c:1216
[<ffffffff82df2103>] SYSC_connect+0x103/0x310 net/socket.c:1553
[<ffffffff82df4a24>] SyS_connect+0x24/0x30 net/socket.c:1538
[<ffffffff81006d91>] do_syscall_32_irqs_on arch/x86/entry/common.c:392
[inline]
[<ffffffff81006d91>] do_fast_syscall_32+0x321/0x8a0
arch/x86/entry/common.c:459
[<ffffffff8377b2aa>] sysenter_flags_fixed+0xd/0x17

Allocated by task 15708:
[<ffffffff81035d76>] save_stack_trace+0x26/0x50
arch/x86/kernel/stacktrace.c:63
[<ffffffff814fdaf3>] save_stack+0x43/0xd0 mm/kasan/kasan.c:512
[<ffffffff814fddbd>] set_track mm/kasan/kasan.c:524 [inline]
[<ffffffff814fddbd>] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:616
[<ffffffff814fa0a4>] __kmalloc+0x124/0x320 mm/slub.c:3613
[<ffffffff82df8d1c>] kmalloc include/linux/slab.h:481 [inline]
[<ffffffff82df8d1c>] sk_prot_alloc+0x18c/0x310 net/core/sock.c:1354
[<ffffffff82dff03a>] sk_alloc+0x3a/0x3a0 net/core/sock.c:1419
[<ffffffff83467b43>] pppol2tp_create+0x33/0x1f0 net/l2tp/l2tp_ppp.c:551
[<ffffffff82800cc1>] pppox_create+0xf1/0x200 drivers/net/ppp/pppox.c:121
[<ffffffff82df3c6c>] __sock_create+0x3ac/0x640 net/socket.c:1177
[<ffffffff82df4130>] sock_create net/socket.c:1217 [inline]
[<ffffffff82df4130>] SYSC_socket net/socket.c:1247 [inline]
[<ffffffff82df4130>] SyS_socket+0xf0/0x1b0 net/socket.c:1227
[<ffffffff81006d91>] do_syscall_32_irqs_on arch/x86/entry/common.c:392
[inline]
[<ffffffff81006d91>] do_fast_syscall_32+0x321/0x8a0
arch/x86/entry/common.c:459
[<ffffffff8377b2aa>] sysenter_flags_fixed+0xd/0x17

Freed by task 15720:
[<ffffffff81035d76>] save_stack_trace+0x26/0x50
arch/x86/kernel/stacktrace.c:63
[<ffffffff814fdaf3>] save_stack+0x43/0xd0 mm/kasan/kasan.c:512
[<ffffffff814fe412>] set_track mm/kasan/kasan.c:524 [inline]
[<ffffffff814fe412>] kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:589
[<ffffffff814faeac>] slab_free_hook mm/slub.c:1383 [inline]
[<ffffffff814faeac>] slab_free_freelist_hook mm/slub.c:1405 [inline]
[<ffffffff814faeac>] slab_free mm/slub.c:2859 [inline]
[<ffffffff814faeac>] kfree+0xfc/0x300 mm/slub.c:3749
[<ffffffff82e02c07>] sk_prot_free net/core/sock.c:1391 [inline]
[<ffffffff82e02c07>] sk_destruct+0x3f7/0x4c0 net/core/sock.c:1472
[<ffffffff82e02d27>] __sk_free+0x57/0x230 net/core/sock.c:1480
[<ffffffff82e02f30>] sk_free+0x30/0x40 net/core/sock.c:1491
[<ffffffff8346b14f>] sock_put include/net/sock.h:1639 [inline]
[<ffffffff8346b14f>] pppol2tp_session_sock_put+0x5f/0x70
net/l2tp/l2tp_ppp.c:286
[<ffffffff83463b44>] l2tp_tunnel_closeall+0x254/0x3b0
net/l2tp/l2tp_core.c:1277
[<ffffffff8346472b>] l2tp_udp_encap_destroy+0x8b/0xf0
net/l2tp/l2tp_core.c:1300
[<ffffffff833729c1>] udpv6_destroy_sock+0xb1/0xd0 net/ipv6/udp.c:1421
[<ffffffff82e048fb>] sk_common_release+0x6b/0x300 net/core/sock.c:2680
[<ffffffff83371975>] udp_lib_close+0x15/0x20 include/net/udp.h:190
[<ffffffff831d5eba>] inet_release+0xfa/0x1d0 net/ipv4/af_inet.c:435
[<ffffffff832fb320>] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:424
[<ffffffff82ded7fd>] sock_release+0x8d/0x1e0 net/socket.c:586
[<ffffffff82ded966>] sock_close+0x16/0x20 net/socket.c:1037
[<ffffffff81523f43>] __fput+0x233/0x6d0 fs/file_table.c:208
[<ffffffff81524465>] ____fput+0x15/0x20 fs/file_table.c:244
[<ffffffff8118bd44>] task_work_run+0x104/0x180 kernel/task_work.c:115
[<ffffffff8100361d>] tracehook_notify_resume include/linux/tracehook.h:191
[inline]
[<ffffffff8100361d>] exit_to_usermode_loop+0x13d/0x160
arch/x86/entry/common.c:252
[<ffffffff81007084>] prepare_exit_to_usermode arch/x86/entry/common.c:283
[inline]
[<ffffffff81007084>] syscall_return_slowpath arch/x86/entry/common.c:348
[inline]
[<ffffffff81007084>] do_syscall_32_irqs_on arch/x86/entry/common.c:398
[inline]
[<ffffffff81007084>] do_fast_syscall_32+0x614/0x8a0
arch/x86/entry/common.c:459
[<ffffffff8377b2aa>] sysenter_flags_fixed+0xd/0x17

The buggy address belongs to the object at ffff8801d89b5500
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1016 bytes inside of
2048-byte region [ffff8801d89b5500, ffff8801d89b5d00)
The buggy address belongs to the page:
mm/pgtable-generic.c:33: bad pmd ffff8801c78926f0(ffff8801d89b6600)
------------[ cut here ]------------
WARNING: CPU: 0 PID: 3782 at lib/list_debug.c:29 __list_add+0x120/0x1c0
lib/list_debug.c:26()
list_add corruption. next->prev should be prev (ffff8801db21fe70), but was
ffffea0007626c00. (next=ffff8801c70e3088).


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages