syzbot


KASAN: use-after-free Read in aead_recvmsg

Status: fixed on 2017/12/21 04:38
Subsystems: crypto
[Documentation on labels]
Reported-by: syzbot+6fbc13c3b1ed2105e7a2e516be43d6a0624a59c0@syzkaller.appspotmail.com
Fix commit: b32a7dc8aef1 crypto: algif_aead - fix reference counting of null skcipher
First crash: 2372d, last: 2349d
Duplicate bugs (2)
duplicates (2):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
KASAN: use-after-free Read in blkcipher_walk_virt crypto 2 2357d 2366d 0/26 closed as dup on 2017/11/30 08:59
BUG: unable to handle kernel NULL pointer dereference net C 35 2346d 2363d 0/26 closed as dup on 2017/12/03 19:29

Sample crash report:
audit: type=1400 audit(1512850514.083:7): avc:  denied  { map } for  pid=3149 comm="syzkaller168370" path="/root/syzkaller168370441" 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: use-after-free in crypto_aead_alg include/crypto/aead.h:198 [inline]
BUG: KASAN: use-after-free in crypto_aead_encrypt include/crypto/aead.h:330 [inline]
BUG: KASAN: use-after-free in _aead_recvmsg crypto/algif_aead.c:308 [inline]
BUG: KASAN: use-after-free in aead_recvmsg+0x1758/0x1bc0 crypto/algif_aead.c:329
Read of size 4 at addr ffff8801c5259e5c by task syzkaller168370/3149

CPU: 0 PID: 3149 Comm: syzkaller168370 Not tainted 4.15.0-rc2+ #214
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
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
 crypto_aead_alg include/crypto/aead.h:198 [inline]
 crypto_aead_encrypt include/crypto/aead.h:330 [inline]
 _aead_recvmsg crypto/algif_aead.c:308 [inline]
 aead_recvmsg+0x1758/0x1bc0 crypto/algif_aead.c:329
 sock_recvmsg_nosec net/socket.c:809 [inline]
 sock_recvmsg+0xc9/0x110 net/socket.c:816
 ___sys_recvmsg+0x29b/0x630 net/socket.c:2185
 __sys_recvmsg+0xe2/0x210 net/socket.c:2230
 SYSC_recvmsg net/socket.c:2242 [inline]
 SyS_recvmsg+0x2d/0x50 net/socket.c:2237
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x440009
RSP: 002b:00007ffee19bc768 EFLAGS: 00000286 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440009
RDX: 0000000000002021 RSI: 0000000020b2dfc8 RDI: 0000000000000004
RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000286 R12: 0000000000401970
R13: 0000000000401a00 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 3149:
 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:3711 [inline]
 __kmalloc+0x162/0x760 mm/slab.c:3720
 kmalloc include/linux/slab.h:504 [inline]
 kzalloc include/linux/slab.h:688 [inline]
 crypto_create_tfm+0x82/0x2e0 crypto/api.c:455
 crypto_alloc_tfm+0x10e/0x2f0 crypto/api.c:540
 crypto_alloc_skcipher+0x2c/0x40 crypto/skcipher.c:929
 crypto_get_default_null_skcipher+0x5f/0x80 crypto/crypto_null.c:164
 crypto_get_default_null_skcipher2 include/crypto/null.h:17 [inline]
 aead_bind+0x89/0x140 crypto/algif_aead.c:488
 alg_bind+0x1ab/0x440 crypto/af_alg.c:179
 SYSC_bind+0x1b4/0x3f0 net/socket.c:1454
 SyS_bind+0x24/0x30 net/socket.c:1440
 entry_SYSCALL_64_fastpath+0x1f/0x96

Freed by task 3149:
 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:3491 [inline]
 kfree+0xca/0x250 mm/slab.c:3806
 kzfree+0x28/0x30 mm/slab_common.c:1482
 crypto_destroy_tfm+0x140/0x2e0 crypto/api.c:581
 crypto_free_skcipher include/crypto/skcipher.h:212 [inline]
 crypto_put_default_null_skcipher+0x35/0x60 crypto/crypto_null.c:185
 crypto_put_default_null_skcipher2 include/crypto/null.h:22 [inline]
 aead_sock_destruct+0x13c/0x220 crypto/algif_aead.c:538
 __sk_destruct+0xfd/0x910 net/core/sock.c:1558
 sk_destruct+0x47/0x80 net/core/sock.c:1593
 __sk_free+0x57/0x230 net/core/sock.c:1601
 sk_free+0x2a/0x40 net/core/sock.c:1612
 sock_put include/net/sock.h:1651 [inline]
 af_alg_release+0x5d/0x70 crypto/af_alg.c:126
 sock_release+0x8d/0x1e0 net/socket.c:600
 sock_close+0x16/0x20 net/socket.c:1129
 __fput+0x333/0x7f0 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 ffff8801c5259e40
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 28 bytes inside of
 128-byte region [ffff8801c5259e40, ffff8801c5259ec0)
The buggy address belongs to the page:
page:00000000ac68fd2d count:1 mapcount:0 mapping:000000003296ebe9 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801c5259000 0000000000000000 0000000100000015
raw: ffffea00071653a0 ffffea0007133320 ffff8801db000640 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801c5259d00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8801c5259d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8801c5259e00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                    ^
 ffff8801c5259e80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8801c5259f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4338):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/12/09 20:17 upstream f335195adf04 5ad0ce95 .config console log report syz C ci-upstream-kasan-gce
2017/12/06 14:19 upstream 328b4ed93b69 0796857b .config console log report syz C ci-upstream-kasan-gce
2017/12/06 04:18 upstream 328b4ed93b69 0796857b .config console log report syz C ci-upstream-kasan-gce
2017/12/05 23:38 upstream fd6d2e506ce6 de212f1a .config console log report syz C ci-upstream-kasan-gce
2017/12/05 19:11 upstream fd6d2e506ce6 de212f1a .config console log report syz C ci-upstream-kasan-gce
2017/12/05 01:43 upstream 2391f0b4808e de212f1a .config console log report syz C ci-upstream-kasan-gce
2017/12/04 03:41 upstream ae64f9bd1d36 48359b97 .config console log report syz C ci-upstream-kasan-gce
2017/12/02 22:40 upstream 2db767d9889c 48359b97 .config console log report syz C ci-upstream-kasan-gce
2017/12/02 19:57 upstream 2db767d9889c 48359b97 .config console log report syz C ci-upstream-kasan-gce
2017/12/02 11:21 upstream a0651c7fa2c0 48359b97 .config console log report syz C ci-upstream-kasan-gce
2017/12/02 04:30 upstream a0651c7fa2c0 48359b97 .config console log report syz C ci-upstream-kasan-gce
2017/12/01 20:24 upstream 3c1c4ddffb58 2fa91450 .config console log report syz C ci-upstream-kasan-gce
2017/12/01 17:39 upstream 3c1c4ddffb58 2fa91450 .config console log report syz C ci-upstream-kasan-gce
2017/12/09 14:41 net-next-old 5e54b3c12027 5ad0ce95 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/03 20:31 net-next-old fb7516d42478 48359b97 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/03 13:26 net-next-old 75d0de8c7e70 48359b97 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/03 06:46 net-next-old 75d0de8c7e70 48359b97 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/02 16:26 net-next-old c5f66a858997 48359b97 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/02 08:42 net-next-old 4c94cc2d3d57 2fa91450 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/02 03:07 net-next-old 4c94cc2d3d57 2fa91450 .config console log report syz C ci-upstream-net-kasan-gce
2017/11/28 07:38 net-next-old 1d3b78bbc6e9 29b0fd90 .config console log report syz C ci-upstream-net-kasan-gce
2017/11/24 15:24 net-next-old 0c86a6bd85ff ddf7b3e0 .config console log report syz C ci-upstream-net-kasan-gce
2017/12/04 04:35 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/03 23:23 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/03 13:27 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/03 13:00 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/03 01:23 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/03 00:42 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/02 16:38 mmots 4131d5166185 29b0fd90 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/11/28 07:18 linux-next 5bef2980adef 1808de66 .config console log report syz C ci-upstream-next-kasan-gce
2017/11/24 16:24 mmots 1ea8d039f9ed deb5f6ae .config console log report syz C ci-upstream-mmots-kasan-gce
2017/11/24 16:00 linux-next 6fc478f80f68 4bd70f88 .config console log report syz C ci-upstream-next-kasan-gce
2017/11/24 14:58 linux-next 6fc478f80f68 4bd70f88 .config console log report syz C ci-upstream-next-kasan-gce
2017/12/06 17:05 upstream 328b4ed93b69 0796857b .config console log report syz ci-upstream-kasan-gce
2017/11/24 14:56 net-next-old 1d3b78bbc6e9 deb5f6ae .config console log report syz ci-upstream-kasan-gce
2017/11/28 07:34 mmots dbf9f9124937 1808de66 .config console log report syz ci-upstream-mmots-kasan-gce
2017/11/24 15:07 mmots 1ea8d039f9ed deb5f6ae .config console log report syz ci-upstream-mmots-kasan-gce
2017/12/01 22:14 upstream 3c1c4ddffb58 2fa91450 .config console log report ci-upstream-kasan-gce
2017/11/27 21:16 upstream 4fbd8d194f06 ac93d7e1 .config console log report ci-upstream-kasan-gce-386
2017/11/26 23:25 upstream 844056fd74eb 4bd70f88 .config console log report ci-upstream-kasan-gce-386
2017/11/26 23:21 net-next-old 1d3b78bbc6e9 deb5f6ae .config console log report ci-upstream-kasan-gce-386
2017/12/16 22:39 net-next-old 28dc4c8f4557 b6f0c91b .config console log report ci-upstream-net-kasan-gce
2017/12/16 21:18 net-next-old 28dc4c8f4557 b6f0c91b .config console log report ci-upstream-net-kasan-gce
2017/12/16 15:26 net-next-old 28dc4c8f4557 b6f0c91b .config console log report ci-upstream-net-kasan-gce
2017/12/16 10:50 net-next-old 28dc4c8f4557 b6f0c91b .config console log report ci-upstream-net-kasan-gce
2017/12/16 05:37 net-next-old 28dc4c8f4557 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/16 03:26 net-next-old 3b07d7884ca2 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/16 02:10 net-next-old 3b07d7884ca2 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/15 20:41 net-next-old 3b07d7884ca2 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/15 17:41 net-next-old 3b07d7884ca2 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/15 10:25 net-next-old 5c13e07580c8 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/14 17:45 net-next-old 5c13e07580c8 ac20b98c .config console log report ci-upstream-net-kasan-gce
2017/12/13 20:28 net-next-old f93ea3bf151d 06ea774d .config console log report ci-upstream-net-kasan-gce
2017/12/13 13:27 net-next-old 48d79b49e168 ce7f2399 .config console log report ci-upstream-net-kasan-gce
2017/12/13 12:09 net-next-old 48d79b49e168 ce7f2399 .config console log report ci-upstream-net-kasan-gce
2017/12/13 07:52 net-next-old 48d79b49e168 ce7f2399 .config console log report ci-upstream-net-kasan-gce
2017/12/13 02:52 net-next-old 48d79b49e168 ce7f2399 .config console log report ci-upstream-net-kasan-gce
2017/12/12 23:23 net-next-old c360f2b58ee4 414a185f .config console log report ci-upstream-net-kasan-gce
2017/12/12 20:37 net-next-old c360f2b58ee4 414a185f .config console log report ci-upstream-net-kasan-gce
2017/12/12 17:21 net-next-old c360f2b58ee4 414a185f .config console log report ci-upstream-net-kasan-gce
2017/12/06 23:16 net-next-old 92425c40676d 5d643f8e .config console log report ci-upstream-net-kasan-gce
2017/12/01 23:25 net-next-old 4c94cc2d3d57 2fa91450 .config console log report ci-upstream-net-kasan-gce
2017/11/27 23:06 net-next-old 1d3b78bbc6e9 29b0fd90 .config console log report ci-upstream-net-kasan-gce
2017/11/27 19:28 net-next-old 1d3b78bbc6e9 29b0fd90 .config console log report ci-upstream-net-kasan-gce
2017/11/27 14:19 net-next-old 1d3b78bbc6e9 29b0fd90 .config console log report ci-upstream-net-kasan-gce
2017/11/27 12:10 net-next-old 1d3b78bbc6e9 deb5f6ae .config console log report ci-upstream-net-kasan-gce
2017/12/01 19:43 mmots 4131d5166185 29b0fd90 .config console log report ci-upstream-mmots-kasan-gce
2017/11/28 04:07 linux-next 5bef2980adef 1808de66 .config console log report ci-upstream-next-kasan-gce
2017/11/28 02:21 linux-next b0a84f19a516 afba0b55 .config console log report ci-upstream-next-kasan-gce
2017/11/28 01:20 linux-next b0a84f19a516 afba0b55 .config console log report ci-upstream-next-kasan-gce
2017/11/27 16:22 linux-next b0a84f19a516 afba0b55 .config console log report ci-upstream-next-kasan-gce
2017/11/27 13:57 mmots 1ea8d039f9ed deb5f6ae .config console log report ci-upstream-mmots-kasan-gce
2017/11/27 12:38 linux-next b0a84f19a516 deb5f6ae .config console log report ci-upstream-next-kasan-gce
2017/11/27 08:09 linux-next b0a84f19a516 deb5f6ae .config console log report ci-upstream-next-kasan-gce
2017/11/27 07:14 linux-next b0a84f19a516 deb5f6ae .config console log report ci-upstream-next-kasan-gce
2017/11/27 01:32 linux-next 6fc478f80f68 4bd70f88 .config console log report ci-upstream-next-kasan-gce
2017/11/27 00:53 linux-next 6fc478f80f68 4bd70f88 .config console log report ci-upstream-next-kasan-gce
* Struck through repros no longer work on HEAD.