linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: crypto: api - Fix use-after-free and race in crypto_spawn_alg
@ 2020-04-10  9:18 Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-04-10  9:18 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto, netdev
  Cc: linux-kernel, syzbot+fc0674cde00b66844470, syzkaller-bugs,
	David S. Miller

> Secondly the setting of the DYING flag is racy because we hold
> the read-lock instead of the write-lock.  We should instead call

Would an imperative wording be preferred for this change description?


> This patch fixes both problems.

Will another wording alternative become relevant?

Are the provided tags sufficient for such information?

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread
* WARNING: refcount bug in crypto_destroy_tfm
@ 2020-04-06 18:16 syzbot
  2020-04-10  6:09 ` crypto: api - Fix use-after-free and race in crypto_spawn_alg Herbert Xu
  0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2020-04-06 18:16 UTC (permalink / raw)
  To: davem, herbert, linux-crypto, linux-kernel, netdev, syzkaller-bugs

Hello,

syzbot found the following crash on:

HEAD commit:    468c2a10 mlxsw: spectrum_trap: fix unintention integer ove..
git tree:       net
console output: https://syzkaller.appspot.com/x/log.txt?x=11089cb3e00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8c1e98458335a7d1
dashboard link: https://syzkaller.appspot.com/bug?extid=fc0674cde00b66844470
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=115f2a43e00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=141ea0ede00000

The bug was bisected to:

commit 4f87ee118d16b4b2116a477229573ed5003b0d78
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Sat Dec 7 14:15:17 2019 +0000

    crypto: api - Do not zap spawn->alg

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=10ffbc2be00000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=12ffbc2be00000
console output: https://syzkaller.appspot.com/x/log.txt?x=14ffbc2be00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+fc0674cde00b66844470@syzkaller.appspotmail.com
Fixes: 4f87ee118d16 ("crypto: api - Do not zap spawn->alg")

------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 0 PID: 7174 at lib/refcount.c:28 refcount_warn_saturate+0x1d1/0x1e0 lib/refcount.c:28
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 7174 Comm: syz-executor413 Not tainted 5.6.0-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+0x1d1/0x1e0 lib/refcount.c:28
Code: e9 db fe ff ff 48 89 df e8 2c 95 1e fe e9 8a fe ff ff e8 c2 81 e1 fd 48 c7 c7 40 c6 71 88 c6 05 82 bd f1 06 01 e8 17 f6 b2 fd <0f> 0b e9 af fe ff ff 0f 1f 84 00 00 00 00 00 41 56 41 55 41 54 55
RSP: 0018:ffffc90001a17b18 EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff815ca861 RDI: fffff52000342f55
RBP: 0000000000000003 R08: ffff8880949fe300 R09: ffffed1015cc66a1
R10: ffffed1015cc66a0 R11: ffff8880ae633507 R12: ffff88809a6d187c
R13: ffff8880a40eb000 R14: 0000000000000000 R15: ffff8880a40eb010
 refcount_sub_and_test include/linux/refcount.h:261 [inline]
 refcount_dec_and_test include/linux/refcount.h:281 [inline]
 crypto_alg_put crypto/internal.h:93 [inline]
 crypto_mod_put crypto/api.c:45 [inline]
 crypto_destroy_tfm+0x2a1/0x310 crypto/api.c:566
 crypto_exit_ops crypto/api.c:308 [inline]
 crypto_destroy_tfm+0xb1/0x310 crypto/api.c:565
 crypto_free_aead include/crypto/aead.h:185 [inline]
 aead_release+0x2d/0x50 crypto/algif_aead.c:506
 alg_do_release crypto/af_alg.c:114 [inline]
 alg_sock_destruct+0x85/0xe0 crypto/af_alg.c:358
 __sk_destruct+0x4b/0x7c0 net/core/sock.c:1696
 sk_destruct+0xc6/0x100 net/core/sock.c:1740
 __sk_free+0xef/0x3d0 net/core/sock.c:1751
 sk_free+0x78/0xa0 net/core/sock.c:1762
 sock_put include/net/sock.h:1778 [inline]
 af_alg_release+0xdb/0x110 crypto/af_alg.c:121
 __sock_release+0xcd/0x280 net/socket.c:605
 sock_close+0x18/0x20 net/socket.c:1283
 __fput+0x2e9/0x860 fs/file_table.c:280
 task_work_run+0xf4/0x1b0 kernel/task_work.c:123
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xb34/0x2dd0 kernel/exit.c:793
 do_group_exit+0x125/0x340 kernel/exit.c:891
 __do_sys_exit_group kernel/exit.c:902 [inline]
 __se_sys_exit_group kernel/exit.c:900 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:900
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x43ff78
Code: 00 00 be 3c 00 00 00 eb 19 66 0f 1f 84 00 00 00 00 00 48 89 d7 89 f0 0f 05 48 3d 00 f0 ff ff 77 21 f4 48 89 d7 44 89 c0 0f 05 <48> 3d 00 f0 ff ff 76 e0 f7 d8 64 41 89 01 eb d8 0f 1f 84 00 00 00
RSP: 002b:00007ffe423e1db8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043ff78
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004bf850 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 00000000004002c8 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d1180 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] 6+ messages in thread

end of thread, other threads:[~2020-04-16  2:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10  9:18 crypto: api - Fix use-after-free and race in crypto_spawn_alg Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-04-06 18:16 WARNING: refcount bug in crypto_destroy_tfm syzbot
2020-04-10  6:09 ` crypto: api - Fix use-after-free and race in crypto_spawn_alg Herbert Xu
2020-04-16  2:17   ` Eric Biggers
2020-04-16  2:25     ` Herbert Xu
2020-04-16  2:30       ` Eric Biggers
2020-04-16  2:42         ` 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).