linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* WARNING: refcount bug in crypto_mod_get
@ 2020-05-01 17:01 syzbot
  2020-06-05 12:38 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2020-05-01 17:01 UTC (permalink / raw)
  To: ardb, davem, herbert, linux-crypto, linux-kernel, syzkaller-bugs,
	t-kristo

Hello,

syzbot found the following crash on:

HEAD commit:    6a8b55ed Linux 5.7-rc3
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11b91564100000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5b075813ec8b93cd
dashboard link: https://syzkaller.appspot.com/bug?extid=afb77bdbaca0cda9e991
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12f8067fe00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17fd8028100000

The bug was bisected to:

commit b877ad1a135c802d4529a72aa82faf46ef5db097
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Tue Nov 5 14:01:04 2019 +0000

    crypto: omap-aes-gcm - check length of assocdata in RFC4106 mode

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=147c2208100000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=167c2208100000
console output: https://syzkaller.appspot.com/x/log.txt?x=127c2208100000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+afb77bdbaca0cda9e991@syzkaller.appspotmail.com
Fixes: b877ad1a135c ("crypto: omap-aes-gcm - check length of assocdata in RFC4106 mode")

------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 0 PID: 7775 at lib/refcount.c:25 refcount_warn_saturate+0x169/0x1e0 lib/refcount.c:25
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 7775 Comm: syz-executor692 Not tainted 5.7.0-rc3-syzkaller #0
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+0x188/0x20d lib/dump_stack.c:118
 panic+0x2e3/0x75c kernel/panic.c:221
 __warn.cold+0x2f/0x35 kernel/panic.c:582
 report_bug+0x27b/0x2f0 lib/bug.c:195
 fixup_bug arch/x86/kernel/traps.c:175 [inline]
 fixup_bug arch/x86/kernel/traps.c:170 [inline]
 do_error_trap+0x12b/0x220 arch/x86/kernel/traps.c:267
 do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:286
 invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1027
RIP: 0010:refcount_warn_saturate+0x169/0x1e0 lib/refcount.c:25
Code: 06 31 ff 89 de e8 87 b9 dc fd 84 db 0f 85 36 ff ff ff e8 4a b8 dc fd 48 c7 c7 a0 5b 72 88 c6 05 b2 1c ee 06 01 e8 4f f3 ad fd <0f> 0b e9 17 ff ff ff e8 2b b8 dc fd 0f b6 1d 97 1c ee 06 31 ff 89
RSP: 0018:ffffc90002797bf8 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff815ce171 RDI: fffff520004f2f71
RBP: 0000000000000002 R08: ffff88809d9e6400 R09: ffffed1015cc66a9
R10: ffff8880ae633547 R11: ffffed1015cc66a8 R12: ffff8880a403a048
R13: ffff88809df99d00 R14: ffffed1013bf33a5 R15: ffff888099925048
 refcount_add include/linux/refcount.h:204 [inline]
 refcount_inc include/linux/refcount.h:241 [inline]
 crypto_alg_get crypto/internal.h:87 [inline]
 crypto_mod_get+0xc6/0xf0 crypto/api.c:37
 crypto_spawn_alg.isra.0+0xa8/0x110 crypto/algapi.c:723
 crypto_spawn_tfm2+0x19/0xb0 crypto/algapi.c:763
 crypto_spawn_aead include/crypto/internal/aead.h:102 [inline]
 pcrypt_aead_init_tfm+0x144/0x273 crypto/pcrypt.c:182
 crypto_aead_init_tfm+0x138/0x1a0 crypto/aead.c:140
 crypto_create_tfm+0xd5/0x2f0 crypto/api.c:454
 crypto_alloc_tfm+0x100/0x340 crypto/api.c:526
 aead_bind+0x69/0x170 crypto/algif_aead.c:483
 alg_bind+0x260/0x530 crypto/af_alg.c:182
 __sys_bind+0x20e/0x250 net/socket.c:1662
 __do_sys_bind net/socket.c:1673 [inline]
 __se_sys_bind net/socket.c:1671 [inline]
 __x64_sys_bind+0x6f/0xb0 net/socket.c:1671
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x441359
Code: e8 ac e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd04b593e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000031
RAX: ffffffffffffffda RBX: 00000000004a2378 RCX: 0000000000441359
RDX: 0000000000000058 RSI: 0000000020000040 RDI: 0000000000000003
RBP: 000000000000e5c5 R08: 00000000004002c8 R09: 00000000004002c8
R10: 0000000000000004 R11: 0000000000000246 R12: 00000000004020d0
R13: 0000000000402160 R14: 0000000000000000 R15: 0000000000000000
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: WARNING: refcount bug in crypto_mod_get
  2020-05-01 17:01 WARNING: refcount bug in crypto_mod_get syzbot
@ 2020-06-05 12:38 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2020-06-05 12:38 UTC (permalink / raw)
  To: syzbot; +Cc: ardb, davem, linux-crypto, linux-kernel, syzkaller-bugs, t-kristo

On Fri, May 01, 2020 at 10:01:14AM -0700, syzbot wrote:
>
> ------------[ cut here ]------------
> refcount_t: addition on 0; use-after-free.
...
>  refcount_add include/linux/refcount.h:204 [inline]
>  refcount_inc include/linux/refcount.h:241 [inline]
>  crypto_alg_get crypto/internal.h:87 [inline]
>  crypto_mod_get+0xc6/0xf0 crypto/api.c:37
>  crypto_spawn_alg.isra.0+0xa8/0x110 crypto/algapi.c:723
>  crypto_spawn_tfm2+0x19/0xb0 crypto/algapi.c:763
>  crypto_spawn_aead include/crypto/internal/aead.h:102 [inline]
>  pcrypt_aead_init_tfm+0x144/0x273 crypto/pcrypt.c:182
>  crypto_aead_init_tfm+0x138/0x1a0 crypto/aead.c:140
>  crypto_create_tfm+0xd5/0x2f0 crypto/api.c:454
>  crypto_alloc_tfm+0x100/0x340 crypto/api.c:526
>  aead_bind+0x69/0x170 crypto/algif_aead.c:483
>  alg_bind+0x260/0x530 crypto/af_alg.c:182
>  __sys_bind+0x20e/0x250 net/socket.c:1662
>  __do_sys_bind net/socket.c:1673 [inline]
>  __se_sys_bind net/socket.c:1671 [inline]
>  __x64_sys_bind+0x6f/0xb0 net/socket.c:1671
>  do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
>  entry_SYSCALL_64_after_hwframe+0x49/0xb3

This should be fixed already:

#syz fix: crypto: api - Fix use-after-free and race in crypto_spawn_alg

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-05 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 17:01 WARNING: refcount bug in crypto_mod_get syzbot
2020-06-05 12:38 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).