KASAN: use-after-free Read in l2tp_session_create

7 views
Skip to first unread message

syzbot

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

syzbot found the following crash on:

HEAD commit: db2c520b ANDROID: sched/tune: fix boost_group spin_lock re..
git tree: android-4.9
console output: https://syzkaller.appspot.com/x/log.txt?x=1412bdf7800000
kernel config: https://syzkaller.appspot.com/x/.config?x=2b0cc69a74f11792
dashboard link: https://syzkaller.appspot.com/bug?extid=f1831eaccce7ca4fa8c8
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1791b8cf800000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12461d6f800000

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

==================================================================
BUG: KASAN: use-after-free in l2tp_session_create+0x160f/0x16f0
net/l2tp/l2tp_core.c:1914
Read of size 4 at addr ffff8801d06b6790 by task syz-executor304/7685

CPU: 0 PID: 7685 Comm: syz-executor304 Not tainted 4.9.107-gdb2c520 #49
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
ffff8801d03e7a20 ffffffff81eb3da9 ffffea000741ad80 ffff8801d06b6790
0000000000000000 ffff8801d06b6790 0000000000000000 ffff8801d03e7a58
ffffffff815679f9 ffff8801d06b6790 0000000000000004 0000000000000000
Call Trace:
[<ffffffff81eb3da9>] __dump_stack lib/dump_stack.c:15 [inline]
[<ffffffff81eb3da9>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
[<ffffffff815679f9>] print_address_description+0x6c/0x234
mm/kasan/report.c:256
[<ffffffff81567e03>] kasan_report_error mm/kasan/report.c:355 [inline]
[<ffffffff81567e03>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
[<ffffffff8153ba34>] __asan_report_load4_noabort+0x14/0x20
mm/kasan/report.c:432
[<ffffffff836c166f>] l2tp_session_create+0x160f/0x16f0
net/l2tp/l2tp_core.c:1914
[<ffffffff836c5e77>] pppol2tp_connect+0x10d7/0x18f0 net/l2tp/l2tp_ppp.c:718
[<ffffffff83017958>] SYSC_connect+0x1b8/0x300 net/socket.c:1562
[<ffffffff8301a224>] SyS_connect+0x24/0x30 net/socket.c:1543
[<ffffffff81006316>] do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
[<ffffffff839f9b13>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 7685:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:505
set_track mm/kasan/kasan.c:517 [inline]
kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:609
__kmalloc+0x11d/0x300 mm/slub.c:3741
kmalloc include/linux/slab.h:495 [inline]
kzalloc include/linux/slab.h:636 [inline]
l2tp_session_create+0x38/0x16f0 net/l2tp/l2tp_core.c:1843
pppol2tp_connect+0x10d7/0x18f0 net/l2tp/l2tp_ppp.c:718
SYSC_connect+0x1b8/0x300 net/socket.c:1562
SyS_connect+0x24/0x30 net/socket.c:1543
do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 7684:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:505
set_track mm/kasan/kasan.c:517 [inline]
kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582
slab_free_hook mm/slub.c:1355 [inline]
slab_free_freelist_hook mm/slub.c:1377 [inline]
slab_free mm/slub.c:2958 [inline]
kfree+0xfb/0x310 mm/slub.c:3878
l2tp_session_free+0x166/0x200 net/l2tp/l2tp_core.c:1770
l2tp_session_dec_refcount_1 net/l2tp/l2tp_core.h:297 [inline]
pppol2tp_connect+0xc55/0x18f0 net/l2tp/l2tp_ppp.c:790
SYSC_connect+0x1b8/0x300 net/socket.c:1562
SyS_connect+0x24/0x30 net/socket.c:1543
do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801d06b6780
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 16 bytes inside of
512-byte region [ffff8801d06b6780, ffff8801d06b6980)
The buggy address belongs to the page:
page:ffffea000741ad80 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x8000000000004080(slab|head)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801d06b6680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d06b6700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8801d06b6780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d06b6800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d06b6880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
------------[ cut here ]------------
kernel BUG at net/l2tp/l2tp_core.c:917!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 7674 Comm: syz-executor304 Tainted: G B
4.9.107-gdb2c520 #49
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
task: ffff8801cec28000 task.stack: ffff8801cec88000
RIP: 0010:[<ffffffff836bb760>] [<ffffffff836bb760>]
l2tp_session_queue_purge+0xe0/0x100 net/l2tp/l2tp_core.c:917
RSP: 0018:ffff8801cec8fb40 EFLAGS: 00010293
RAX: ffff8801cec28000 RBX: ffff8801d06b6780 RCX: ffffffff836bb774
RDX: 0000000000000000 RSI: ffffffff836bb760 RDI: ffff8801d06b6780
RBP: ffff8801cec8fb68 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: dffffc0000000000
R13: ffff8801d06b6780 R14: 0000000000000000 R15: ffff8801d766e7d8
FS: 00007f13edde6700(0000) GS:ffff8801db200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fff995ca434 CR3: 00000001cfffc000 CR4: 00000000001606f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Stack:
ffff8801d06b6828 dffffc0000000000 ffff8801d06b6780 0000000000000000
ffff8801d766e7d8 ffff8801cec8fbc0 ffffffff836bd04f ffff8801d766e858
ffffed003aecdcfb ffff8801d766e7d8 ffff8801d766e7a0 ffff8801d766e780
Call Trace:
[<ffffffff836bd04f>] l2tp_tunnel_closeall+0x1ff/0x350
net/l2tp/l2tp_core.c:1365
[<ffffffff836bd902>] l2tp_tunnel_destruct+0x2f2/0x590
net/l2tp/l2tp_core.c:1324
[<ffffffff83021095>] __sk_destruct+0x55/0x590 net/core/sock.c:1428
[<ffffffff83028b23>] sk_destruct+0x63/0x80 net/core/sock.c:1463
[<ffffffff83028b8f>] __sk_free+0x4f/0x220 net/core/sock.c:1471
[<ffffffff83028d8b>] sk_free+0x2b/0x40 net/core/sock.c:1482
[<ffffffff836bc8cc>] sock_put include/net/sock.h:1588 [inline]
[<ffffffff836bc8cc>] l2tp_session_free+0x19c/0x200
net/l2tp/l2tp_core.c:1765
[<ffffffff836c4132>] l2tp_session_dec_refcount_1 net/l2tp/l2tp_core.h:297
[inline]
[<ffffffff836c4132>] pppol2tp_session_destruct+0xd2/0x110
net/l2tp/l2tp_ppp.c:460
[<ffffffff83021095>] __sk_destruct+0x55/0x590 net/core/sock.c:1428
[<ffffffff83028b23>] sk_destruct+0x63/0x80 net/core/sock.c:1463
[<ffffffff83028b8f>] __sk_free+0x4f/0x220 net/core/sock.c:1471
[<ffffffff83028d8b>] sk_free+0x2b/0x40 net/core/sock.c:1482
[<ffffffff836c7439>] sock_put include/net/sock.h:1588 [inline]
[<ffffffff836c7439>] pppol2tp_release+0x239/0x2e0 net/l2tp/l2tp_ppp.c:501
[<ffffffff83013ab6>] sock_release+0x96/0x1c0 net/socket.c:599
[<ffffffff83013bf6>] sock_close+0x16/0x20 net/socket.c:1046
[<ffffffff81578103>] __fput+0x263/0x700 fs/file_table.c:208
[<ffffffff81578625>] ____fput+0x15/0x20 fs/file_table.c:244
[<ffffffff8119832c>] task_work_run+0x10c/0x180 kernel/task_work.c:116
[<ffffffff8100559c>] tracehook_notify_resume include/linux/tracehook.h:191
[inline]
[<ffffffff8100559c>] exit_to_usermode_loop+0xfc/0x120
arch/x86/entry/common.c:161
[<ffffffff810064d4>] prepare_exit_to_usermode arch/x86/entry/common.c:191
[inline]
[<ffffffff810064d4>] syscall_return_slowpath arch/x86/entry/common.c:260
[inline]
[<ffffffff810064d4>] do_syscall_64+0x364/0x490 arch/x86/entry/common.c:287
[<ffffffff839f9b13>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb
Code: 32 ca fd 31 c0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 f6 31 ca fd 48 89
df e8 4e 7c 34 00 eb ca e8 e7 31 ca fd 0f 0b e8 e0 31 ca fd <0f> 0b 4c 89
ff e8 d6 02 e8 fd eb a6 48 89 df e8 ac 02 e8 fd e9
RIP [<ffffffff836bb760>] l2tp_session_queue_purge+0xe0/0x100
net/l2tp/l2tp_core.c:917
RSP <ffff8801cec8fb40>


---
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