syzbot


KASAN: stack-out-of-bounds Write in sha3_update

Status: fixed on 2017/12/21 04:38
Subsystems: crypto
[Documentation on labels]
Reported-by: syzbot+6f724d52da8e3ff8872545bd8444f50f0d174c5f@syzkaller.appspotmail.com
Fix commit: af3ff8045bbf crypto: hmac - require that the underlying hash algorithm is unkeyed
First crash: 2344d, last: 2344d
Duplicate bugs (3)
duplicates (3):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
KASAN: stack-out-of-bounds Write in sha3_final crypto C 5 2344d 2340d 0/26 closed as dup on 2017/11/28 19:13
KASAN: slab-out-of-bounds Write in sha3_final crypto C 4 2344d 2340d 0/26 closed as dup on 2017/11/28 19:13
KASAN: slab-out-of-bounds Write in sha3_update crypto C 18 2318d 2340d 0/26 closed as dup on 2017/11/28 21:35

Sample crash report:
==================================================================
BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:341 [inline]
BUG: KASAN: stack-out-of-bounds in sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
Write of size 4096 at addr ffff8801cca2fc40 by task syzkaller319830/3053

CPU: 0 PID: 3053 Comm: syzkaller319830 Not tainted 4.14.0+ #192
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
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
 memcpy+0x37/0x50 mm/kasan/kasan.c:303
 memcpy include/linux/string.h:341 [inline]
 sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
 crypto_shash_update+0xcb/0x220 crypto/shash.c:109
 shash_finup_unaligned+0x2a/0x60 crypto/shash.c:151
 crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
 hmac_finup+0x182/0x330 crypto/hmac.c:152
 crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
 shash_digest_unaligned+0x9e/0xd0 crypto/shash.c:172
 crypto_shash_digest+0xc4/0x120 crypto/shash.c:186
 hmac_setkey+0x36a/0x690 crypto/hmac.c:66
 crypto_shash_setkey+0xad/0x190 crypto/shash.c:64
 shash_async_setkey+0x47/0x60 crypto/shash.c:207
 crypto_ahash_setkey+0xaf/0x180 crypto/ahash.c:200
 hash_setkey+0x40/0x90 crypto/algif_hash.c:446
 alg_setkey crypto/af_alg.c:221 [inline]
 alg_setsockopt+0x2a1/0x350 crypto/af_alg.c:254
 SYSC_setsockopt net/socket.c:1851 [inline]
 SyS_setsockopt+0x189/0x360 net/socket.c:1830
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x43fdb9
RSP: 002b:00007ffcc9c271c8 EFLAGS: 00000217 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fdb9
RDX: 0000000000000001 RSI: 0000000000000117 RDI: 0000000000000003
RBP: 0000000000000086 R08: 0000000000001000 R09: 0000000000000000
R10: 0000000020ea5000 R11: 0000000000000217 R12: 0000000000401720
R13: 00000000004017b0 R14: 0000000000000000 R15: 0000000000000000

The buggy address belongs to the page:
page:ffffea0007328bc0 count:0 mapcount:0 mapping:          (null) index:0x0
flags: 0x2fffc0000000000()
raw: 02fffc0000000000 0000000000000000 0000000000000000 00000000ffffffff
raw: 0000000000000000 0000000100000001 0000000000000000 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cca2fd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801cca2fe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8801cca2fe80: f1 f1 f1 f1 04 f2 f2 f2 f2 f2 f2 f2 04 f2 f2 f2
                   ^
 ffff8801cca2ff00: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801cca2ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/11/24 15:09 net-next-old 1d3b78bbc6e9 deb5f6ae .config console log report syz C ci-upstream-kasan-gce
2017/11/24 14:57 net-next-old 1d3b78bbc6e9 deb5f6ae .config console log report syz C ci-upstream-kasan-gce
2017/11/24 15:37 net-next-old 0c86a6bd85ff ddf7b3e0 .config console log report syz C ci-upstream-net-kasan-gce
2017/11/24 15:20 mmots 1ea8d039f9ed deb5f6ae .config console log report syz C ci-upstream-mmots-kasan-gce
2017/11/24 15:11 linux-next 6fc478f80f68 4bd70f88 .config console log report syz C ci-upstream-next-kasan-gce
* Struck through repros no longer work on HEAD.