On Tue, Feb 10, 2009 at 03:35:03PM +0200, Pekka Enberg wrote: > > We unexported ksize() because it's a problematic interface and you > > almost certainly want to use the alternatives (e.g. krealloc). I think > > I need bit more convincing to apply this patch... On Tue, 10 Feb 2009, Kirill A. Shutemov wrote: > It just a quick fix. If anybody knows better solution, I have no > objections. Herbert, what do you think of this (untested) patch? Alternatively, we could do something like kfree_secure() but it seems overkill for this one call-site. Pekka >From 7dddc378c19a6d203f147e503d5254df34eda6ae Mon Sep 17 00:00:00 2001 From: Pekka Enberg <penberg@xxxxxxxxxxxxxx> Date: Tue, 10 Feb 2009 16:01:27 +0200 Subject: [PATCH] crypto: api - don't use ksize() The ksize() function is not exported to modules because it has non-standard behavour across different slab allocators. While it is technically ok for this particular call-site, we do not want the use of the API to spread so fix it up by adding a ->size member to struct crypto_tfm and use that instead. Cc: Geert Uytterhoeven <Geert.Uytterhoeven@xxxxxxxxxxx> Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx> --- crypto/api.c | 6 +++--- include/linux/crypto.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto/api.c b/crypto/api.c index efe77df..3526cc0 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -374,6 +374,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, goto out_err; tfm->__crt_alg = alg; + tfm->size = tfm_size; err = crypto_init_ops(tfm, type, mask); if (err) @@ -471,6 +472,7 @@ struct crypto_tfm *crypto_create_tfm(struct crypto_alg *alg, tfm = (struct crypto_tfm *)(mem + tfmsize); tfm->__crt_alg = alg; + tfm->size = total; err = frontend->init_tfm(tfm, frontend); if (err) @@ -569,19 +571,17 @@ EXPORT_SYMBOL_GPL(crypto_alloc_tfm); void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm) { struct crypto_alg *alg; - int size; if (unlikely(!mem)) return; alg = tfm->__crt_alg; - size = ksize(mem); if (!tfm->exit && alg->cra_exit) alg->cra_exit(tfm); crypto_exit_ops(tfm); crypto_mod_put(alg); - memset(mem, 0, size); + memset(mem, 0, tfm->size); kfree(mem); } EXPORT_SYMBOL_GPL(crypto_destroy_tfm); diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 1f2e902..4fd363a 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -487,6 +487,8 @@ struct crypto_tfm { struct crypto_alg *__crt_alg; + size_t size; + void *__crt_ctx[] CRYPTO_MINALIGN_ATTR; }; -- 1.5.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html