linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: arm64/aes - do not call crypto_unregister_skcipher twice on error
@ 2017-11-22  8:08 Corentin Labbe
  2017-11-22  8:55 ` Ard Biesheuvel
  0 siblings, 1 reply; 4+ messages in thread
From: Corentin Labbe @ 2017-11-22  8:08 UTC (permalink / raw)
  To: herbert, davem, catalin.marinas, will.deacon
  Cc: linux-crypto, linux-arm-kernel, linux-kernel, Corentin Labbe

When a cipher fail to register in aes_init(), the error path go thought
aes_exit() then crypto_unregister_skciphers().
Since aes_exit calls also crypto_unregister_skcipher, this trigger a
refcount_t: underflow; use-after-free.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 arch/arm64/crypto/aes-glue.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c
index 998ba519a026..9e42ec96243e 100644
--- a/arch/arm64/crypto/aes-glue.c
+++ b/arch/arm64/crypto/aes-glue.c
@@ -664,7 +664,10 @@ static int __init aes_init(void)
 	return 0;
 
 unregister_simds:
-	aes_exit();
+	for (i = 0; i < ARRAY_SIZE(aes_simd_algs); i++)
+		if (aes_simd_algs[i])
+			simd_skcipher_free(aes_simd_algs[i]);
+	crypto_unregister_shashes(mac_algs, ARRAY_SIZE(mac_algs));
 unregister_ciphers:
 	crypto_unregister_skciphers(aes_algs, ARRAY_SIZE(aes_algs));
 	return err;
-- 
2.13.6

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

end of thread, other threads:[~2017-11-24  5:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22  8:08 [PATCH] crypto: arm64/aes - do not call crypto_unregister_skcipher twice on error Corentin Labbe
2017-11-22  8:55 ` Ard Biesheuvel
2017-11-24  4:55   ` Herbert Xu
2017-11-24  5:52   ` LABBE Corentin

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).