]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
crypto: pcrypt - Fix user-after-free on module unload
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 19 Nov 2019 09:41:31 +0000 (17:41 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 6 Mar 2020 07:13:20 +0000 (02:13 -0500)
BugLink: https://bugs.launchpad.net/bugs/1864904
[ Upstream commit 07bfd9bdf568a38d9440c607b72342036011f727 ]

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: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
crypto/pcrypt.c

index a5718c0a3dc4e8ea4a02121f972f1d31193f48e3..1348541da463a0cfe57a20e2fa9ddef432194d96 100644 (file)
@@ -505,11 +505,12 @@ err:
 
 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);
 }
 
 module_init(pcrypt_init);