syzbot


KASAN: use-after-free Read in skcipher_recvmsg

Status: fixed on 2019/01/11 01:22
Subsystems: crypto
[Documentation on labels]
Reported-by: syzbot+6939a606a5305e9e9799@syzkaller.appspotmail.com
Fix commit: f7d76e05d058 crypto: user - fix use_after_free of struct xxx_request
First crash: 2174d, last: 2150d
Discussions (6)
Title Replies (including bot) Last reply
[PATCH v5 00/11] crypto: crypto_user_stat: misc enhancement 16 (16) 2018/12/07 06:18
[PATCH v4 00/11] crypto: crypto_user_stat: misc enhancement 14 (14) 2018/11/28 23:17
[PATCH v3 00/10] crypto: crypto_user_stat: misc enhancement 12 (12) 2018/11/20 14:13
[PATCH v2 00/11] crypto: crypto_user_stat: misc enhancement 16 (16) 2018/11/20 05:48
[PATCH 0/5] crypto: crypto_user_stat: misc enhancement 14 (14) 2018/11/07 19:34
KASAN: use-after-free Read in skcipher_recvmsg 2 (3) 2018/11/04 11:18

Sample crash report:
netlink: 'syz-executor4': attribute type 4 has an invalid length.
==================================================================
BUG: KASAN: use-after-free in crypto_stat_skcipher_encrypt include/crypto/skcipher.h:497 [inline]
BUG: KASAN: use-after-free in crypto_skcipher_encrypt include/crypto/skcipher.h:535 [inline]
BUG: KASAN: use-after-free in _skcipher_recvmsg crypto/algif_skcipher.c:130 [inline]
BUG: KASAN: use-after-free in skcipher_recvmsg+0x1627/0x1780 crypto/algif_skcipher.c:165
Read of size 4 at addr ffff8881cd33c300 by task syz-executor3/27286

CPU: 0 PID: 27286 Comm: syz-executor3 Not tainted 4.20.0-rc3+ #128
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 crypto_stat_skcipher_encrypt include/crypto/skcipher.h:497 [inline]
 crypto_skcipher_encrypt include/crypto/skcipher.h:535 [inline]
 _skcipher_recvmsg crypto/algif_skcipher.c:130 [inline]
 skcipher_recvmsg+0x1627/0x1780 crypto/algif_skcipher.c:165
 skcipher_recvmsg_nokey+0x69/0x90 crypto/algif_skcipher.c:283
 sock_recvmsg_nosec net/socket.c:794 [inline]
 sock_recvmsg+0xd0/0x110 net/socket.c:801
 sock_read_iter+0x39b/0x570 net/socket.c:878
 call_read_iter include/linux/fs.h:1851 [inline]
 aio_read+0x297/0x490 fs/aio.c:1516
 io_submit_one+0xac2/0xf80 fs/aio.c:1832
 __do_sys_io_submit fs/aio.c:1916 [inline]
 __se_sys_io_submit fs/aio.c:1887 [inline]
 __x64_sys_io_submit+0x1b7/0x580 fs/aio.c:1887
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457569
Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fdeec70dc78 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457569
RDX: 00000000201f5ff8 RSI: 0000000000000001 RDI: 00007fdeec6cd000
RBP: 000000000072bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fdeec70e6d4
R13: 00000000004be7ed R14: 00000000004ced68 R15: 00000000ffffffff

Allocated by task 27286:
 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:3722 [inline]
 __kmalloc+0x15b/0x760 mm/slab.c:3731
 kmalloc include/linux/slab.h:551 [inline]
 sock_kmalloc+0x15a/0x1f0 net/core/sock.c:1984
 af_alg_alloc_areq+0x83/0x280 crypto/af_alg.c:1097
 _skcipher_recvmsg crypto/algif_skcipher.c:75 [inline]
 skcipher_recvmsg+0x354/0x1780 crypto/algif_skcipher.c:165
 skcipher_recvmsg_nokey+0x69/0x90 crypto/algif_skcipher.c:283
 sock_recvmsg_nosec net/socket.c:794 [inline]
 sock_recvmsg+0xd0/0x110 net/socket.c:801
 sock_read_iter+0x39b/0x570 net/socket.c:878
 call_read_iter include/linux/fs.h:1851 [inline]
 aio_read+0x297/0x490 fs/aio.c:1516
 io_submit_one+0xac2/0xf80 fs/aio.c:1832
 __do_sys_io_submit fs/aio.c:1916 [inline]
 __se_sys_io_submit fs/aio.c:1887 [inline]
 __x64_sys_io_submit+0x1b7/0x580 fs/aio.c:1887
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 6193:
 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:3817
 __sock_kfree_s net/core/sock.c:2005 [inline]
 sock_kfree_s+0x29/0x60 net/core/sock.c:2011
 af_alg_free_resources+0x6b/0x80 crypto/af_alg.c:1033
 af_alg_async_cb+0xbc/0x180 crypto/af_alg.c:1056
 cryptd_skcipher_complete+0x14c/0x250 crypto/cryptd.c:474
 cryptd_skcipher_encrypt+0x4e2/0x750 crypto/cryptd.c:506
 cryptd_queue_worker+0x12d/0x200 crypto/cryptd.c:193
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881cd33c000
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 768 bytes inside of
 1024-byte region [ffff8881cd33c000, ffff8881cd33c400)
The buggy address belongs to the page:
page:ffffea000734cf00 count:1 mapcount:0 mapping:ffff8881da800ac0 index:0xffff8881cd33d200 compound_mapcount: 0
flags: 0x2fffc0000010200(slab|head)
raw: 02fffc0000010200 ffffea0007331908 ffffea00071a0288 ffff8881da800ac0
raw: ffff8881cd33d200 ffff8881cd33c000 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881cd33c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881cd33c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881cd33c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8881cd33c380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881cd33c400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/11/25 22:18 upstream d6d460b89378 3d3ec907 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/07 14:13 upstream 8053e5b93eca 8bd6bd63 .config console log report ci-upstream-kasan-gce
2018/11/01 06:30 upstream 59fc453b21f7 1f38e9ae .config console log report ci-upstream-kasan-gce
2018/11/25 20:55 linux-next 442b8cea2477 3d3ec907 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/11/18 22:10 linux-next 442b8cea2477 adf636a8 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/11/13 23:21 linux-next 442b8cea2477 5f5f6d14 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.