lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0902101605070.20991@melkki.cs.Helsinki.FI>
Date:	Tue, 10 Feb 2009 16:06:53 +0200 (EET)
From:	Pekka J Enberg <penberg@...helsinki.fi>
To:	"Kirill A. Shutemov" <kirill@...temov.name>
cc:	Christoph Lameter <cl@...ux-foundation.org>,
	Matt Mackall <mpm@...enic.com>, linux-kernel@...r.kernel.org,
	linux-mm@...ck.org, linux-crypto@...r.kernel.org,
	Herbert Xu <herbert@...dor.apana.org.au>,
	Geert.Uytterhoeven@...ycom.com
Subject: Re: [PATCH] Export symbol ksize()

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@...helsinki.fi>
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@...ycom.com>
Cc: Herbert Xu <herbert@...dor.apana.org.au>
Signed-off-by: Pekka Enberg <penberg@...helsinki.fi>
---
 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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ