syzbot


KASAN: use-after-free Read in sha512_ctx_mgr_resubmit

Status: fixed on 2018/11/12 21:25
Subsystems: crypto
[Documentation on labels]
Reported-by: syzbot+d5455bac3ba1ee9114e5@syzkaller.appspotmail.com
Fix commit: ab8085c130ed crypto: x86 - remove SHA multibuffer routines and mcryptd
First crash: 2305d, last: 2254d
Duplicate bugs (1)
duplicates (1):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
KASAN: use-after-free Read in sha512_mb_flusher crypto 1 2305d 2303d 0/28 closed as dup on 2018/08/21 02:46
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in sha512_ctx_mgr_resubmit 7 (8) 2018/10/05 22:33

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in sha512_ctx_mgr_resubmit.part.3+0x3b1/0x4a0 arch/x86/crypto/sha512-mb/sha512_mb.c:136
Read of size 4 at addr ffff8801d4870578 by task kworker/1:1/24

CPU: 1 PID: 24 Comm: kworker/1:1 Not tainted 4.19.0-rc6+ #266
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: crypto mcryptd_flusher
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1c4/0x2b4 lib/dump_stack.c:113
 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 sha512_ctx_mgr_resubmit.part.3+0x3b1/0x4a0 arch/x86/crypto/sha512-mb/sha512_mb.c:136
 sha512_ctx_mgr_resubmit arch/x86/crypto/sha512-mb/sha512_mb.c:135 [inline]
 sha512_ctx_mgr_flush+0x5c/0xb0 arch/x86/crypto/sha512-mb/sha512_mb.c:367
 sha512_mb_flusher+0x27b/0x610 arch/x86/crypto/sha512-mb/sha512_mb.c:943
 mcryptd_flusher+0x340/0x4b0 crypto/mcryptd.c:208
 process_one_work+0xc90/0x1b90 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x420 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:413

Allocated by task 6003:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3718 [inline]
 __kmalloc+0x14e/0x760 mm/slab.c:3727
 kmalloc include/linux/slab.h:518 [inline]
 sock_kmalloc+0x15a/0x1f0 net/core/sock.c:1983
 hash_accept_parent_nokey+0x58/0x2e0 crypto/algif_hash.c:438
 hash_accept_parent+0x5b/0x80 crypto/algif_hash.c:465
 af_alg_accept+0x127/0x7d0 crypto/af_alg.c:296
 alg_accept+0x46/0x60 crypto/af_alg.c:332
 __sys_accept4+0x3b2/0x8a0 net/socket.c:1590
 __do_sys_accept4 net/socket.c:1625 [inline]
 __se_sys_accept4 net/socket.c:1622 [inline]
 __x64_sys_accept4+0x97/0xf0 net/socket.c:1622
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 6002:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3813
 __sock_kfree_s net/core/sock.c:2004 [inline]
 sock_kfree_s+0x29/0x60 net/core/sock.c:2010
 hash_sock_destruct+0x157/0x1c0 crypto/algif_hash.c:427
 __sk_destruct+0x107/0xa80 net/core/sock.c:1560
 sk_destruct+0x78/0x90 net/core/sock.c:1595
 __sk_free+0xcf/0x300 net/core/sock.c:1606
 sk_free+0x42/0x50 net/core/sock.c:1617
 sock_put include/net/sock.h:1691 [inline]
 af_alg_release+0x6e/0x90 crypto/af_alg.c:126
 __sock_release+0xd7/0x250 net/socket.c:579
 sock_close+0x19/0x20 net/socket.c:1141
 __fput+0x385/0xa30 fs/file_table.c:278
 ____fput+0x15/0x20 fs/file_table.c:309
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801d4870080
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1272 bytes inside of
 2048-byte region [ffff8801d4870080, ffff8801d4870880)
The buggy address belongs to the page:
page:ffffea0007521c00 count:1 mapcount:0 mapping:ffff8801da800c40 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffffea0007526108 ffffea0007528008 ffff8801da800c40
raw: 0000000000000000 ffff8801d4870080 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d4870400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d4870480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801d4870500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff8801d4870580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d4870600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/10/04 14:40 upstream cec4de302c5f 8b311eaf .config console log report syz C ci-upstream-kasan-gce
2018/10/04 12:59 upstream cec4de302c5f 8b311eaf .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/08/14 05:32 upstream 7796916146b8 7a88b141 .config console log report syz C ci-upstream-kasan-gce-root
2018/08/14 01:40 linux-next 5ed5da74de9e 7a88b141 .config console log report syz ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.