From patchwork Tue Nov 19 09:41:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 11251647 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B84B14C0 for ; Tue, 19 Nov 2019 09:41:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24D8422304 for ; Tue, 19 Nov 2019 09:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726590AbfKSJlk (ORCPT ); Tue, 19 Nov 2019 04:41:40 -0500 Received: from helcar.hmeau.com ([216.24.177.18]:37036 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727435AbfKSJlk (ORCPT ); Tue, 19 Nov 2019 04:41:40 -0500 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1iX00t-0001uJ-Jx; Tue, 19 Nov 2019 17:41:35 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1iX00p-0004qI-Od; Tue, 19 Nov 2019 17:41:31 +0800 Date: Tue, 19 Nov 2019 17:41:31 +0800 From: Herbert Xu To: Linux Crypto Mailing List , Daniel Jordan , Steffen Klassert , linux-kernel@vger.kernel.org Subject: [PATCH] crypto: pcrypt - Fix user-after-free on module unload Message-ID: <20191119094131.x7gkxdi5clyxk3zd@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On module unload of pcrypt we must unregister the crypto algorithms first and then tear down the padata structure. As otherwise the crypto algorithms are still alive and can be used while the padata structure is being freed. Fixes: 5068c7a883d1 ("crypto: pcrypt - Add pcrypt crypto...") Cc: Signed-off-by: Herbert Xu diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c index 543792e0ebf0..3e026e7a7e75 100644 --- a/crypto/pcrypt.c +++ b/crypto/pcrypt.c @@ -362,11 +392,12 @@ static int __init pcrypt_init(void) static void __exit pcrypt_exit(void) { + crypto_unregister_template(&pcrypt_tmpl); + pcrypt_fini_padata(pencrypt); pcrypt_fini_padata(pdecrypt); kset_unregister(pcrypt_kset); - crypto_unregister_template(&pcrypt_tmpl); } subsys_initcall(pcrypt_init);