KASAN: use-after-free in aead_recvmsg

Status: fixed on 2017/12/27 08:45
Subsystems: crypto
[Documentation on labels]
Fix commit: b32a7dc8aef1 crypto: algif_aead - fix reference counting of null skcipher
First crash: 2190d, last: 2190d

Sample crash report:
audit: type=1400 audit(1512839595.369:14): avc:  denied  { net_raw } for  pid=3421 comm="syz-executor6" capability=13  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns 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
audit: type=1400 audit(1512839595.408:15): avc:  denied  { net_admin } for  pid=3434 comm="syz-executor7" capability=12  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns permissive=1
BUG: unable to handle kernel NULL pointer dereference at           (null)
IP:           (null)
PGD 1c0f30067 P4D 1c0f30067 PUD 1c20b5067 PMD 0 
Oops: 0010 [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 3428 Comm: syz-executor6 Not tainted 4.15.0-rc2+ #147
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
task: 000000007885cbc4 task.stack: 00000000d29e99f4
RIP: 0010:          (null)
RSP: 0018:ffff8801bd8af958 EFLAGS: 00010286
RAX: ffff8801c4ae0b40 RBX: 1ffff10037b15f2c RCX: ffffffff823a8fbd
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff8801bd8af960
RBP: ffff8801bd8afb00 R08: 0000000000000000 R09: ffff8801c367c000
R10: 0000000000000008 R11: ffffed00386cf807 R12: ffff8801bdb08d58
R13: ffff8801c4ae0b68 R14: ffff8801bd8af960 R15: dffffc0000000000
FS:  00007fcfc62b8700(0000) GS:ffff8801db500000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 00000001c258e000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 sock_recvmsg_nosec net/socket.c:805 [inline]
 sock_recvmsg+0xc9/0x110 net/socket.c:812
 ___sys_recvmsg+0x29b/0x630 net/socket.c:2207
 __sys_recvmsg+0xe2/0x210 net/socket.c:2252
 SYSC_recvmsg net/socket.c:2264 [inline]
 SyS_recvmsg+0x2d/0x50 net/socket.c:2259
RIP: 0033:0x452a39
RSP: 002b:00007fcfc62b7c58 EFLAGS: 00000212 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 00000000007580d8 RCX: 0000000000452a39
RDX: 0000000000000040 RSI: 00000000207e0000 RDI: 0000000000000014
RBP: 0000000000758100 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000212 R12: 0000000000000000
R13: 0000000000a6f7ff R14: 00007fcfc62b89c0 R15: 0000000000000006
Code:  Bad RIP value.
RIP:           (null) RSP: ffff8801bd8af958
CR2: 0000000000000000
---[ end trace 16653a125b60e908 ]---

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/12/09 17:13 net-next-old 5e54b3c12027 5ad0ce95 .config console log report ci-upstream-net-kasan-gce
2017/12/09 14:15 net-next-old 5e54b3c12027 5ad0ce95 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.