lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACT4Y+YkMuNshsowPFeO896n+Q862pbFy6Z3X2w0z-=upr1Mzw@mail.gmail.com>
Date:	Tue, 12 Jan 2016 10:29:23 +0100
From:	Dmitry Vyukov <dvyukov@...gle.com>
To:	Herbert Xu <herbert@...dor.apana.org.au>,
	"David S. Miller" <davem@...emloft.net>,
	linux-crypto@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Cc:	syzkaller <syzkaller@...glegroups.com>,
	Kostya Serebryany <kcc@...gle.com>,
	Alexander Potapenko <glider@...gle.com>,
	Sasha Levin <sasha.levin@...cle.com>,
	Eric Dumazet <edumazet@...gle.com>
Subject: Re: crypto: ablk_decrypt causes BUG in scatterwalk

On Tue, Jan 12, 2016 at 10:27 AM, Dmitry Vyukov <dvyukov@...gle.com> wrote:
> Hello,
>
> The following program cause BUG in scatterwalk:
>
>
> // autogenerated by syzkaller (http://github.com/google/syzkaller)
> #include <unistd.h>
> #include <sys/syscall.h>
> #include <string.h>
> #include <stdint.h>
> #include <pthread.h>
>
> long r[30];
>
> void *thr(void *arg)
> {
>         switch ((long)arg) {
>         case 0:
>                 r[0] = syscall(SYS_mmap, 0x20000000ul, 0x32000ul,
> 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul);
>                 break;
>         case 1:
>                 r[1] = syscall(SYS_socket, 0x26ul, 0x5ul, 0x0ul, 0, 0, 0);
>                 break;
>         case 2:
>                 *(uint16_t*)0x2000c8ab = (uint16_t)0x26;
>                 memcpy((void*)0x2000c8ad,
> "\x73\x6b\x63\x69\x70\x68\x65\x72\x00\x00\x00\x00\x00\x00", 14);
>                 *(uint32_t*)0x2000c8bb = (uint32_t)0x8;
>                 *(uint32_t*)0x2000c8bf = (uint32_t)0xb;
>                 memcpy((void*)0x2000c8c3,
> "\x6c\x72\x77\x28\x73\x65\x72\x70\x65\x6e\x74\x29\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
> 64);
>                 r[7] = syscall(SYS_bind, r[1], 0x2000c8abul, 0x58ul, 0, 0, 0);
>                 break;
>         case 3:
>                 memcpy((void*)0x2002cb94,
> "\xdc\x4f\x77\x67\x54\xf2\x23\xd1\xbe\x5c\x6b\x02\xa6\x65\xc1\x0f\x74\xbd\xca\x88\x2e\x8c",
> 22);
>                 r[9] = syscall(SYS_setsockopt, r[1], 0x117ul, 0x1ul,
> 0x2002cb94ul, 0x16ul, 0);
>                 break;
>         case 4:
>                 r[10] = syscall(SYS_accept4, r[1], 0x0ul,
> 0x2001f000ul, 0x80000ul, 0, 0);
>                 break;
>         case 5:
>                 memcpy((void*)0x2002f622,
> "\x3d\xfd\xfe\x62\xbf\xa7\xa7\xdf\x4c\x40\x8f\x45\x46\x69\x27\x93\xa7\x35\x0b\xc6\xc9\x2b\xa2\x31\xf2\x9e\xb7\xb4\xaa\x9f\x96\xc1\x27\xf0\x9d\x3e\x81\xeb\xdc\x31\x02\x6c\x6c\xbc\xf5\xab\x5a\x25\x26\x76\x31\x4b\x4c\x50\xc4\xf6\x99\x1e\x69\xfc\x47\x49\xee\x12\xc4\xf3\x6c\x97\x58\xa6\xa6\xf8\x1c\x3d\x43\xcc\x6f\x6e\x9d\x89\x85\xb2\x53\x27\x43\xf7\x62\xcc\xa9\x6b\xda\x8f\xeb\x21\xa6\x49\xae\xb5\xf5\x43\x23\xbd\xe2\x29\x5c\x5d\x08\xa4\xd2\xb6\x7d\x72\x4f\x99\x38\x01\xd7\x31\x7b\xa3\xf1\xbb\x85\xf4\x9a\xb1\xa2\x9d\x03\xcb\x74\x7b\x5d\xf9\x83\x02\xd9\xc6\x74\x02\xd7\x01\xf9\xcb\x96\x05\x71\x94\x39\xd4\xc2\x27\xdd\x0f\x13\x72\x90\xdf\x84\xa9\x8f\x70\xb5\x7a",
> 164);
>                 memcpy((void*)0x2002f000, "\x05\x00", 2);
>                 r[13] = syscall(SYS_sendto, r[10], 0x2002f622ul,
> 0xa4ul, 0x8000ul, 0x2002f000ul, 0x2ul);
>                 break;
>         case 6:
>                 *(uint64_t*)0x20030e26 = (uint64_t)0x20002fb5;
>                 *(uint32_t*)0x20030e2e = (uint32_t)0x80;
>                 *(uint64_t*)0x20030e36 = (uint64_t)0x20030000;
>                 *(uint64_t*)0x20030e3e = (uint64_t)0x4;
>                 *(uint64_t*)0x20030e46 = (uint64_t)0x20030bd7;
>                 *(uint64_t*)0x20030e4e = (uint64_t)0xcd;
>                 *(uint32_t*)0x20030e56 = (uint32_t)0x4f3e;
>                 *(uint64_t*)0x20030000 = (uint64_t)0x20030f76;
>                 *(uint64_t*)0x20030008 = (uint64_t)0xfa;
>                 *(uint64_t*)0x20030010 = (uint64_t)0x20030240;
>                 *(uint64_t*)0x20030018 = (uint64_t)0x72;
>                 *(uint64_t*)0x20030020 = (uint64_t)0x20030fb2;
>                 *(uint64_t*)0x20030028 = (uint64_t)0x83;
>                 *(uint64_t*)0x20030030 = (uint64_t)0x200304cf;
>                 *(uint64_t*)0x20030038 = (uint64_t)0xde;
>                 r[29] = syscall(SYS_recvmmsg, r[10], 0x20030e26ul,
> 0x1ul, 0x20ul, 0, 0);
>                 break;
>         }
>         return 0;
> }
>
> int main()
> {
>         long i;
>         pthread_t th[7];
>
>         memset(r, -1, sizeof(r));
>         for (i = 0; i < 7; i++) {
>                 pthread_create(&th[i], 0, thr, (void*)i);
>                 usleep(10000);
>         }
>         for (i = 0; i < 7; i++) {
>                 pthread_create(&th[i], 0, thr, (void*)i);
>                 if (i%2==0)
>                         usleep(10000);
>         }
>         usleep(100000);
>         return 0;
> }
>
>
> ------------[ cut here ]------------
> kernel BUG at crypto/scatterwalk.c:37!
> invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN
> Modules linked in:
> CPU: 1 PID: 6684 Comm: syz-executor Not tainted 4.4.0+ #221
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> task: ffff880060d7de00 ti: ffff880065348000 task.ti: ffff880065348000
> RIP: 0010:[<ffffffff82733529>]  [<ffffffff82733529>]
> scatterwalk_start.part.3+0x9/0x10
> RSP: 0018:ffff88006534f400  EFLAGS: 00010297
> RAX: ffff880060d7de00 RBX: ffff880037623150 RCX: ffff8800364b7310
> RDX: 0000000000000000 RSI: ffff880037623150 RDI: ffff880037623164
> RBP: ffff88006534f400 R08: ffff88006534f6b0 R09: ffff880037623148
> R10: ffffed0006ec4638 R11: 1ffff10006ec4629 R12: ffff88006534f580
> R13: 0000000000000000 R14: ffff88006534f5d8 R15: ffff88006534f560
> FS:  00007fb85fc02700(0000) GS:ffff88003ed00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> CR2: 0000000000451a70 CR3: 000000006257f000 CR4: 00000000000006e0
> Stack:
>  ffff88006534f420 ffffffff827335f6 ffff88006534f820 ffff88006534f598
>  ffff88006534f478 ffffffff8273d640 ffffed000c4afb00 ffff880035581f60
>  0000000020031000 ffff8800364b7310 ffff88006534f560 ffff88006534f820
> Call Trace:
>  [<ffffffff827335f6>] scatterwalk_start+0xc6/0xf0 crypto/scatterwalk.c:40
>  [<ffffffff8273d640>] blkcipher_walk_first+0x170/0x4d0 crypto/blkcipher.c:341
>  [<ffffffff8273dbb9>] blkcipher_walk_virt+0x219/0x2a0 crypto/blkcipher.c:307
>  [<ffffffff8278256b>] lrw_crypt+0x14b/0x990 crypto/lrw.c:234
>  [<ffffffff812a9ea8>] lrw_decrypt+0x128/0x1a0
> arch/x86/crypto/serpent_avx2_glue.c:281
>  [<ffffffff828590c7>] ablk_decrypt+0x187/0x420 crypto/ablk_helper.c:108
>  [<     inline     >] skcipher_crypt_ablkcipher crypto/skcipher.c:157
>  [<ffffffff8273f2c2>] skcipher_decrypt_ablkcipher+0x312/0x420
> crypto/skcipher.c:175
>  [<     inline     >] crypto_skcipher_decrypt include/crypto/skcipher.h:356
>  [<     inline     >] skcipher_recvmsg_sync crypto/algif_skcipher.c:680
>  [<ffffffff82849123>] skcipher_recvmsg+0x11d3/0x1c80 crypto/algif_skcipher.c:710
>  [<     inline     >] sock_recvmsg_nosec net/socket.c:713
>  [<ffffffff84d3aafd>] sock_recvmsg+0x9d/0xb0 net/socket.c:721
>  [<ffffffff84d3de29>] ___sys_recvmsg+0x259/0x540 net/socket.c:2099
>  [<ffffffff84d402d9>] __sys_recvmmsg+0x219/0x7b0 net/socket.c:2205
>  [<     inline     >] SYSC_recvmmsg net/socket.c:2279
>  [<ffffffff84d409df>] SyS_recvmmsg+0x16f/0x180 net/socket.c:2268
>  [<ffffffff85e74936>] entry_SYSCALL_64_fastpath+0x16/0x7a
> arch/x86/entry/entry_64.S:185
> Code: 41 5d 41 5e 41 5f 5d c3 e8 65 0f 00 ff e9 66 ff ff ff e8 5b 0f
> 00 ff eb ae 66 0f 1f 84 00 00 00 00 00 55 48 89 e5 e8 07 c8 e2 fe <0f>
> 0b 0f 1f 44 00 00 55 48 89 e5 41 54 53 49 89 fc 48 89 f3 e8
> RIP  [<ffffffff82733529>] scatterwalk_start.part.3+0x9/0x10
> crypto/scatterwalk.c:37
>  RSP <ffff88006534f400>
> ------------[ cut here ]------------
>
> ------------[ cut here ]------------
> kernel BUG at include/linux/scatterlist.h:123!
> invalid opcode: 0000 [#49] SMP DEBUG_PAGEALLOC KASAN
> Modules linked in:
> CPU: 0 PID: 7643 Comm: syz-executor Tainted: G      D         4.4.0+ #221
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> task: ffff88003e282f00 ti: ffff8800372a8000 task.ti: ffff8800372a8000
> RIP: 0010:[<ffffffff8273ce05>]  [<ffffffff8273ce05>]
> blkcipher_walk_next+0xb55/0x1220
> RSP: 0018:ffff8800372af3a8  EFLAGS: 00010297
> RAX: ffff88003e282f00 RBX: ffff8800372af560 RCX: 0000000087654321
> RDX: 0000000000000000 RSI: 1ffff10006e33639 RDI: ffff88003719b15c
> RBP: ffff8800372af420 R08: ffff8800372af6b0 R09: 000000000000008a
> R10: 0000000000000010 R11: 1ffff10006e33629 R12: 0000000000000000
> R13: 00000000000000a0 R14: ffff8800372af590 R15: 0000000000000000
> FS:  00007fb85fc02700(0000) GS:ffff88003ec00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> CR2: 0000000020030e26 CR3: 0000000035615000 CR4: 00000000000006f0
> Stack:
>  ffffffff8176d8cf 0000000000000000 ffff880035fcdcf8 ffff8800372af598
>  ffff8800372af5cc ffff8800372af580 ffff88003719b1c8 ffff88003719b148
>  8000000088fb30b0 ffff880000000f76 ffff8800372af820 ffff8800372af598
> Call Trace:
>  [<ffffffff8273d699>] blkcipher_walk_first+0x1c9/0x4d0 crypto/blkcipher.c:345
>  [<ffffffff8273dbb9>] blkcipher_walk_virt+0x219/0x2a0 crypto/blkcipher.c:307
>  [<ffffffff8278256b>] lrw_crypt+0x14b/0x990 crypto/lrw.c:234
>  [<ffffffff812a9ea8>] lrw_decrypt+0x128/0x1a0
> arch/x86/crypto/serpent_avx2_glue.c:281
>  [<ffffffff828590c7>] ablk_decrypt+0x187/0x420 crypto/ablk_helper.c:108
>  [<     inline     >] skcipher_crypt_ablkcipher crypto/skcipher.c:157
>  [<ffffffff8273f2c2>] skcipher_decrypt_ablkcipher+0x312/0x420
> crypto/skcipher.c:175
>  [<     inline     >] crypto_skcipher_decrypt include/crypto/skcipher.h:356
>  [<     inline     >] skcipher_recvmsg_sync crypto/algif_skcipher.c:680
>  [<ffffffff82849123>] skcipher_recvmsg+0x11d3/0x1c80 crypto/algif_skcipher.c:710
>  [<     inline     >] sock_recvmsg_nosec net/socket.c:713
>  [<ffffffff84d3aafd>] sock_recvmsg+0x9d/0xb0 net/socket.c:721
>  [<ffffffff84d3de29>] ___sys_recvmsg+0x259/0x540 net/socket.c:2099
>  [<ffffffff84d402d9>] __sys_recvmmsg+0x219/0x7b0 net/socket.c:2205
>  [<     inline     >] SYSC_recvmmsg net/socket.c:2279
>  [<ffffffff84d409df>] SyS_recvmmsg+0x16f/0x180 net/socket.c:2268
>  [<ffffffff85e74936>] entry_SYSCALL_64_fastpath+0x16/0x7a
> arch/x86/entry/entry_64.S:185
> Code: e0 07 83 c0 03 38 d0 7c 09 84 d2 74 05 e8 84 76 ff fe 44 8b 6b
> 6c 45 31 e4 41 83 cd 02 44 89 6b 6c e9 0a fa ff ff e8 2b 2f e2 fe <0f>
> 0b e8 24 2f e2 fe 0f 0b 48 89 f7 e8 5a 76 ff fe e9 4d f5 ff
> RIP  [<     inline     >] blkcipher_next_fast include/linux/scatterlist.h:123
> RIP  [<ffffffff8273ce05>] blkcipher_walk_next+0xb55/0x1220
> crypto/blkcipher.c:264
>  RSP <ffff8800372af3a8>
> ------------[ cut here ]------------
>
>
> On commit afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc (Jan 10) + several
> pending crypto fixes from Herbert:
> https://gist.githubusercontent.com/dvyukov/fad55a75c516033c50a9/raw/e7297c104e0146807591dc0bc6c768b688f3b9af/gistfile1.txt


I've also seen a slightly different call stack:

------------[ cut here ]------------
kernel BUG at include/linux/scatterlist.h:123!
invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN
Modules linked in:
CPU: 0 PID: 8285 Comm: syz-executor Not tainted 4.4.0+ #221
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff880063674680 ti: ffff880053918000 task.ti: ffff880053918000
RIP: 0010:[<ffffffff8273ce05>]  [<ffffffff8273ce05>]
blkcipher_walk_next+0xb55/0x1220
RSP: 0018:ffff88005391f7f8  EFLAGS: 00010287
RAX: ffffffff8273ce05 RBX: ffff88005391fa00 RCX: ffffc900025dc000
RDX: 0000000000000364 RSI: 0000000000000365 RDI: ffff88001454a90c
RBP: ffff88005391f870 R08: ffffed00028a9528 R09: 0000000000000ff9
R10: 0000000000000008 R11: 1ffff100028a951f R12: 0000000000000000
R13: 0000000000000050 R14: ffff88005391fa30 R15: 00000000fffffff0
FS:  00007f4719c8a700(0000) GS:ffff88003ec00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000020024000 CR3: 0000000000c6d000 CR4: 00000000000006f0
Stack:
 ffff880000000001 ffff880063674680 ffffffff8825d308 ffff88005391fa38
 ffff88005391fa6c ffff88005391fa20 ffff88001454ac98 ffff88001454a8f8
 ffffffff1454ac98 0000000000000007 ffff88005391fb08 ffff88005391fa38
Call Trace:
 [<ffffffff8273d699>] blkcipher_walk_first+0x1c9/0x4d0 crypto/blkcipher.c:345
 [<ffffffff8273e0fc>] blkcipher_walk_virt_block+0x21c/0x2a0
crypto/blkcipher.c:357
 [<ffffffff81298386>] ctr_crypt+0xb6/0x5b0
arch/x86/crypto/serpent_avx2_glue.c:156
 [<     inline     >] skcipher_crypt_blkcipher crypto/skcipher.c:66
 [<ffffffff8273e934>] skcipher_decrypt_blkcipher+0x1b4/0x260
crypto/skcipher.c:84
 [<     inline     >] crypto_skcipher_decrypt include/crypto/skcipher.h:356
 [<     inline     >] skcipher_recvmsg_sync crypto/algif_skcipher.c:680
 [<ffffffff82849123>] skcipher_recvmsg+0x11d3/0x1c80 crypto/algif_skcipher.c:710
 [<     inline     >] sock_recvmsg_nosec net/socket.c:713
 [<ffffffff84d3aafd>] sock_recvmsg+0x9d/0xb0 net/socket.c:721
 [<ffffffff84d3b171>] SYSC_recvfrom+0x1e1/0x330 net/socket.c:1702
 [<ffffffff84d3f360>] SyS_recvfrom+0x40/0x50 net/socket.c:1675
 [<ffffffff85e74936>] entry_SYSCALL_64_fastpath+0x16/0x7a
arch/x86/entry/entry_64.S:185
Code: e0 07 83 c0 03 38 d0 7c 09 84 d2 74 05 e8 84 76 ff fe 44 8b 6b
6c 45 31 e4 41 83 cd 02 44 89 6b 6c e9 0a fa ff ff e8 2b 2f e2 fe <0f>
0b e8 24 2f e2 fe 0f 0b 48 89 f7 e8 5a 76 ff fe e9 4d f5 ff
RIP  [<     inline     >] blkcipher_next_fast include/linux/scatterlist.h:123
RIP  [<ffffffff8273ce05>] blkcipher_walk_next+0xb55/0x1220
crypto/blkcipher.c:264
 RSP <ffff88005391f7f8>
---[ end trace 14e82e4e86a6d5f0 ]---

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ