Thread (2 messages) 2 messages, 2 authors, 2017-11-29

KASAN: use-after-free Read in crypto_chacha20_crypt

From: syzbot <hidden>
Date: 2017-11-28 15:23:04
Also in: lkml

Hello,

syzkaller hit the following crash on 1ea8d039f9edcfefb20d8ddfe136930f6e551529
git://git.cmpxchg.org/linux-mmots.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.
C reproducer is attached
syzkaller reproducer is attached. See https://goo.gl/kgGztJ
for information about syzkaller reproducers


==================================================================
BUG: KASAN: use-after-free in __le32_to_cpup include/uapi/linux/byteorder/little_endian.h:58 [inline]
BUG: KASAN: use-after-free in le32_to_cpuvp crypto/chacha20_generic.c:19 [inline]
BUG: KASAN: use-after-free in crypto_chacha20_init crypto/chacha20_generic.c:58 [inline]
BUG: KASAN: use-after-free in crypto_chacha20_crypt+0xaf1/0xbd0 crypto/chacha20_generic.c:91
Read of size 4 at addr ffff880100000006 by task syzkaller030711/3690

CPU: 0 PID: 3690 Comm: syzkaller030711 Not tainted 4.14.0-mm1+ #25
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x25b/0x340 mm/kasan/report.c:409
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
 __le32_to_cpup include/uapi/linux/byteorder/little_endian.h:58 [inline]
 le32_to_cpuvp crypto/chacha20_generic.c:19 [inline]
 crypto_chacha20_init crypto/chacha20_generic.c:58 [inline]
 crypto_chacha20_crypt+0xaf1/0xbd0 crypto/chacha20_generic.c:91
 chacha20_simd+0xe4/0x410 arch/x86/crypto/chacha20_glue.c:78
 crypto_skcipher_decrypt include/crypto/skcipher.h:463 [inline]
 _skcipher_recvmsg crypto/algif_skcipher.c:133 [inline]
 skcipher_recvmsg+0xb06/0xf30 crypto/algif_skcipher.c:164
 skcipher_recvmsg_nokey+0x60/0x80 crypto/algif_skcipher.c:283
 sock_recvmsg_nosec net/socket.c:805 [inline]
 sock_recvmsg+0xc9/0x110 net/socket.c:812
 ___sys_recvmsg+0x29b/0x630 net/socket.c:2207
 __sys_recvmsg+0xe2/0x210 net/socket.c:2252
 SYSC_recvmsg net/socket.c:2264 [inline]
 SyS_recvmsg+0x2d/0x50 net/socket.c:2259
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x4465a9
RSP: 002b:00007f95f86dddc8 EFLAGS: 00000202 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004465a9
RDX: 0000000040010101 RSI: 000000002008dfc8 RDI: 0000000000000006
RBP: 0000000000000086 R08: 00007f95f86de700 R09: 00007f95f86de700
R10: 00007f95f86de700 R11: 0000000000000202 R12: 0000000000000000
R13: 00007ffd7fbd37cf R14: 00007f95f86de9c0 R15: 0000000000000000

The buggy address belongs to the page:
page:ffffea0004000000 count:0 mapcount:-127 mapping:          (null) index:0x0
flags: 0x2fffc0000000000()
raw: 02fffc0000000000 0000000000000000 0000000000000000 00000000ffffff80
raw: ffff88021fffae20 ffffea0004010020 000000000000000a 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
BUG: unable to handle kernel paging request at ffffed001fffffe0
IP: memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:53
PGD 21ffd6067 P4D 21ffd6067 PUD 21ffd5067 PMD 0
Oops: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 3690 Comm: syzkaller030711 Not tainted 4.14.0-mm1+ #25
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
task: ffff8801cb608580 task.stack: ffff8801cb610000
RIP: 0010:memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:53
RSP: 0018:ffff8801cb6174f8 EFLAGS: 00010096
RAX: ffff8801cb617504 RBX: ffffed001fffffe0 RCX: 0000000000000010
RDX: 0000000000000010 RSI: ffffed001fffffe0 RDI: ffff8801cb617504
RBP: ffff8801cb617550 R08: ffffed00396c2ea5 R09: ffffed00396c2ea5
R10: dffffc0000000000 R11: ffffed00396c2ea4 R12: 00000000fffffffe
R13: ffff8800ffffff00 R14: ffffed0020000000 R15: 0000000000000014
FS:  00007f95f86de700(0000) GS:ffff8801db400000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffed001fffffe0 CR3: 00000001cbd94000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 kasan_report_error mm/kasan/report.c:353 [inline]
 kasan_report+0x26f/0x340 mm/kasan/report.c:409
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
 __le32_to_cpup include/uapi/linux/byteorder/little_endian.h:58 [inline]
 le32_to_cpuvp crypto/chacha20_generic.c:19 [inline]
 crypto_chacha20_init crypto/chacha20_generic.c:58 [inline]
 crypto_chacha20_crypt+0xaf1/0xbd0 crypto/chacha20_generic.c:91
 chacha20_simd+0xe4/0x410 arch/x86/crypto/chacha20_glue.c:78
 crypto_skcipher_decrypt include/crypto/skcipher.h:463 [inline]
 _skcipher_recvmsg crypto/algif_skcipher.c:133 [inline]
 skcipher_recvmsg+0xb06/0xf30 crypto/algif_skcipher.c:164
 skcipher_recvmsg_nokey+0x60/0x80 crypto/algif_skcipher.c:283
 sock_recvmsg_nosec net/socket.c:805 [inline]
 sock_recvmsg+0xc9/0x110 net/socket.c:812
 ___sys_recvmsg+0x29b/0x630 net/socket.c:2207
 __sys_recvmsg+0xe2/0x210 net/socket.c:2252
 SYSC_recvmsg net/socket.c:2264 [inline]
 SyS_recvmsg+0x2d/0x50 net/socket.c:2259
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x4465a9
RSP: 002b:00007f95f86dddc8 EFLAGS: 00000202 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004465a9
RDX: 0000000040010101 RSI: 000000002008dfc8 RDI: 0000000000000006
RBP: 0000000000000086 R08: 00007f95f86de700 R09: 00007f95f86de700
R10: 00007f95f86de700 R11: 0000000000000202 R12: 0000000000000000
R13: 00007ffd7fbd37cf R14: 00007f95f86de9c0 R15: 0000000000000000
Code: 90 90 90 90 90 eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38
RIP: memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:53 RSP: ffff8801cb6174f8
CR2: ffffed001fffffe0
---[ end trace 8af5cceb02f4097e ]---


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkaller@googlegroups.com.
Please credit me with: Reported-by: syzbot [off-list ref]

syzbot will keep track of this bug report.
Once a fix for this bug is committed, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug report.
Note: all commands must start from beginning of the line in the email body.

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help