syzbot


KASAN: slab-out-of-bounds Write in sha3_update (2)

Status: fixed on 2018/02/01 10:32
Subsystems: crypto
[Documentation on labels]
Reported-by: syzbot+80f661b525da04e7baaef60ee883f18be36f3942@syzkaller.appspotmail.com
Fix commit: 9fa68f620041 crypto: hash - prevent using keyed hashes without setting key
First crash: 2288d, last: 2248d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Write in sha3_update crypto C 18 2289d 2311d 0/26 closed as dup on 2017/11/28 21:35

Sample crash report:
audit: type=1400 audit(1513919078.260:7): avc:  denied  { map } for  pid=3152 comm="syzkaller717822" path="/root/syzkaller717822551" dev="sda1" ino=16481 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:344 [inline]
BUG: KASAN: slab-out-of-bounds in sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
Write of size 192 at addr ffff8801cf0e3b3c by task syzkaller717822/3152

CPU: 0 PID: 3152 Comm: syzkaller717822 Not tainted 4.15.0-rc4+ #232
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:344 [inline]
 sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
 crypto_shash_update+0xda/0x240 crypto/shash.c:110
 hmac_update+0x7e/0xa0 crypto/hmac.c:122
 crypto_shash_update+0xda/0x240 crypto/shash.c:110
 kdf_ctr security/keys/dh.c:181 [inline]
 keyctl_dh_compute_kdf security/keys/dh.c:226 [inline]
 __keyctl_dh_compute+0x160f/0x1990 security/keys/dh.c:398
 keyctl_dh_compute+0xac/0xf3 security/keys/dh.c:434
 SYSC_keyctl security/keys/keyctl.c:1741 [inline]
 SyS_keyctl+0x72/0x2c0 security/keys/keyctl.c:1637
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x43feb9
RSP: 002b:00007ffd3aef51a8 EFLAGS: 00000217 ORIG_RAX: 00000000000000fa
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043feb9
RDX: 0000000020c2cfff RSI: 00000000204c8ff4 RDI: 0000000000000017
RBP: 00000000006ca018 R08: 00000000208e6fd4 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000217 R12: 0000000000401820
R13: 00000000004018b0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 3152:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
 __do_kmalloc mm/slab.c:3708 [inline]
 __kmalloc+0x162/0x760 mm/slab.c:3717
 kmalloc include/linux/slab.h:504 [inline]
 kdf_alloc security/keys/dh.c:111 [inline]
 __keyctl_dh_compute+0x2b0/0x1990 security/keys/dh.c:288
 keyctl_dh_compute+0xac/0xf3 security/keys/dh.c:434
 SYSC_keyctl security/keys/keyctl.c:1741 [inline]
 SyS_keyctl+0x72/0x2c0 security/keys/keyctl.c:1637
 entry_SYSCALL_64_fastpath+0x1f/0x96

Freed by task 1637:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3488 [inline]
 kfree+0xd6/0x260 mm/slab.c:3803
 kernfs_fop_release+0x13f/0x180 fs/kernfs/file.c:783
 __fput+0x327/0x7e0 fs/file_table.c:210
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x199/0x270 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x296/0x310 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
 entry_SYSCALL_64_fastpath+0x94/0x96

The buggy address belongs to the object at ffff8801cf0e3a40
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 252 bytes inside of
 512-byte region [ffff8801cf0e3a40, ffff8801cf0e3c40)
The buggy address belongs to the page:
page:000000001ae65fa7 count:1 mapcount:0 mapping:0000000077bf18b4 index:0xffff8801cf0e3cc0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801cf0e3040 ffff8801cf0e3cc0 0000000100000005
raw: ffff8801db001738 ffffea00073c1c20 ffff8801db000940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cf0e3a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801cf0e3b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8801cf0e3b80: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
                                              ^
 ffff8801cf0e3c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801cf0e3c80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
==================================================================

Crashes (49):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/12/22 05:06 upstream 9035a8961b50 81fe66b4 .config console log report syz C ci-upstream-kasan-gce
2017/12/22 04:52 upstream 9035a8961b50 81fe66b4 .config console log report syz C ci-upstream-kasan-gce-386
2017/12/23 11:47 linux-next 0e08c463db38 73aba437 .config console log report syz C ci-upstream-next-kasan-gce
2017/12/22 17:49 mmots 37759fa6d0fa 81fe66b4 .config console log report syz C ci-upstream-mmots-kasan-gce
2018/01/26 11:59 upstream 993ca2068b04 1d18b112 .config console log report ci-upstream-kasan-gce
2018/01/23 20:06 upstream 1995266727fa a5b7566c .config console log report ci-upstream-kasan-gce
2018/01/18 13:42 upstream 1d966eb4d632 56cc113a .config console log report ci-upstream-kasan-gce
2018/01/10 11:38 upstream cf1fb158230e 02a19b64 .config console log report ci-upstream-kasan-gce
2018/01/08 23:03 upstream b2cd1df66037 93b4c6f1 .config console log report ci-upstream-kasan-gce
2018/01/08 17:40 upstream b2cd1df66037 93b4c6f1 .config console log report ci-upstream-kasan-gce
2017/12/31 11:00 upstream 71ee203389f7 bb6384b8 .config console log report ci-upstream-kasan-gce
2017/12/28 06:10 upstream 5f520fc31876 7d240098 .config console log report ci-upstream-kasan-gce
2017/12/27 09:58 upstream beacbc68ac3e 09c8f4c0 .config console log report ci-upstream-kasan-gce
2017/12/25 22:43 upstream 464e1d5f23cc 73aba437 .config console log report ci-upstream-kasan-gce
2017/12/25 18:06 upstream 464e1d5f23cc 73aba437 .config console log report ci-upstream-kasan-gce
2017/12/25 08:47 upstream 464e1d5f23cc 73aba437 .config console log report ci-upstream-kasan-gce
2018/01/31 01:22 upstream 72906f38934a 02553e22 .config console log report ci-upstream-kasan-gce-386
2018/01/18 20:45 upstream dda3e15231b3 161c1d64 .config console log report ci-upstream-kasan-gce-386
2018/01/18 10:35 upstream 1d966eb4d632 56cc113a .config console log report ci-upstream-kasan-gce-386
2018/01/17 14:53 upstream 8cbab92dff77 a46e5318 .config console log report ci-upstream-kasan-gce-386
2018/01/12 00:29 upstream 5f615b97cdea 9dc808a6 .config console log report ci-upstream-kasan-gce-386
2018/01/09 09:23 upstream d32da5841b0f 11dc42f6 .config console log report ci-upstream-kasan-gce-386
2018/01/03 08:20 upstream 30a7acd57389 00193447 .config console log report ci-upstream-kasan-gce-386
2017/12/22 09:03 upstream 9035a8961b50 81fe66b4 .config console log report ci-upstream-kasan-gce-386
2017/12/22 04:37 upstream 9035a8961b50 81fe66b4 .config console log report ci-upstream-kasan-gce-386
2018/01/12 19:12 mmots 2c405fa05106 9dc808a6 .config console log report ci-upstream-mmots-kasan-gce
2018/01/11 15:12 linux-next 8418f8876404 9dc808a6 .config console log report ci-upstream-next-kasan-gce
2018/01/10 13:40 linux-next b4464bcab38d 02a19b64 .config console log report ci-upstream-next-kasan-gce
2018/01/09 11:38 linux-next 895c0dde3985 11dc42f6 .config console log report ci-upstream-next-kasan-gce
2018/01/09 09:57 mmots 69eed2290e1d 11dc42f6 .config console log report ci-upstream-mmots-kasan-gce
2018/01/07 07:52 mmots 69eed2290e1d 19c05fff .config console log report ci-upstream-mmots-kasan-gce
2018/01/07 06:47 mmots 69eed2290e1d 19c05fff .config console log report ci-upstream-mmots-kasan-gce
2018/01/04 07:34 mmots ad036b63ee57 00193447 .config console log report ci-upstream-mmots-kasan-gce
2018/01/03 05:50 mmots ad036b63ee57 00193447 .config console log report ci-upstream-mmots-kasan-gce
2018/01/02 17:10 linux-next e0e99813fb1d 00193447 .config console log report ci-upstream-next-kasan-gce
2018/01/02 07:42 linux-next 0e08c463db38 00193447 .config console log report ci-upstream-next-kasan-gce
2018/01/01 15:07 mmots 37759fa6d0fa 00193447 .config console log report ci-upstream-mmots-kasan-gce
2017/12/30 17:19 linux-next 0e08c463db38 bb6384b8 .config console log report ci-upstream-next-kasan-gce
2017/12/30 03:51 mmots 37759fa6d0fa bb6384b8 .config console log report ci-upstream-mmots-kasan-gce
2017/12/29 19:37 linux-next 0e08c463db38 7d240098 .config console log report ci-upstream-next-kasan-gce
2017/12/28 14:10 linux-next 0e08c463db38 7d240098 .config console log report ci-upstream-next-kasan-gce
2017/12/27 01:51 mmots 37759fa6d0fa 73aba437 .config console log report ci-upstream-mmots-kasan-gce
2017/12/25 23:43 mmots 37759fa6d0fa 73aba437 .config console log report ci-upstream-mmots-kasan-gce
2017/12/25 21:51 mmots 37759fa6d0fa 73aba437 .config console log report ci-upstream-mmots-kasan-gce
* Struck through repros no longer work on HEAD.