User: Password:
|
|
Subscribe / Log in / New account

crypto: api - Fix zeroing on free

From:  Linux Kernel Mailing List <linux-kernel-AT-vger.kernel.org>
To:  git-commits-head-AT-vger.kernel.org
Subject:  crypto: api - Fix zeroing on free
Date:  Mon, 9 Feb 2009 17:59:08 GMT
Message-ID:  <200902091759.n19Hx8ad006054@hera.kernel.org>
Archive-link:  Article

Gitweb:
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/li...
Commit:     7b2cd92adc5430b0c1adeb120971852b4ea1ab08
Parent:     4abfd73e34e7915e62b6f75bd3e9f4014f830910
Author:     Herbert Xu <herbert@gondor.apana.org.au>
AuthorDate: Thu Feb 5 16:48:24 2009 +1100
Committer:  Herbert Xu <herbert@gondor.apana.org.au>
CommitDate: Thu Feb 5 16:48:53 2009 +1100

    crypto: api - Fix zeroing on free
    
    Geert Uytterhoeven pointed out that we're not zeroing all the
    memory when freeing a transform.  This patch fixes it by calling
    ksize to ensure that we zero everything in sight.
    
    Reported-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/api.c           |   20 ++++++++++----------
 include/linux/crypto.h |    7 ++++++-
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/crypto/api.c b/crypto/api.c
index 9975a7b..efe77df 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -557,34 +557,34 @@ err:
 	return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
- 
+
 /*
- *	crypto_free_tfm - Free crypto transform
+ *	crypto_destroy_tfm - Free crypto transform
+ *	@mem: Start of tfm slab
  *	@tfm: Transform to free
  *
- *	crypto_free_tfm() frees up the transform and any associated resources,
+ *	This function frees up the transform and any associated resources,
  *	then drops the refcount on the associated algorithm.
  */
-void crypto_free_tfm(struct crypto_tfm *tfm)
+void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
 {
 	struct crypto_alg *alg;
 	int size;
 
-	if (unlikely(!tfm))
+	if (unlikely(!mem))
 		return;
 
 	alg = tfm->__crt_alg;
-	size = sizeof(*tfm) + alg->cra_ctxsize;
+	size = ksize(mem);
 
 	if (!tfm->exit && alg->cra_exit)
 		alg->cra_exit(tfm);
 	crypto_exit_ops(tfm);
 	crypto_mod_put(alg);
-	memset(tfm, 0, size);
-	kfree(tfm);
+	memset(mem, 0, size);
+	kfree(mem);
 }


(Log in to post comments)


Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds