* [PATCH] crypto: Mark tfm buffer as non leak.
@ 2020-09-03 13:40 Peter Enderborg
2020-09-04 7:17 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Peter Enderborg @ 2020-09-03 13:40 UTC (permalink / raw)
To: linux-crypto, linux-kernel, Herbert Xu, David S . Miller; +Cc: Peter Enderborg
When running kmemleak on this I got a lot of
unreferenced object 0xfffffff942d4ec00 (size 1024):
comm "init", pid 1, jiffies 4294893619 (age 17475.864s)
hex dump (first 32 bytes):
38 1d cf bd 9e ff ff ff b8 37 8b bd 9e ff ff ff 8........7......
78 38 8b bd 9e ff ff ff 10 00 00 00 00 00 00 00 x8..............
backtrace:
[<00000000c3c55a80>] __kmalloc+0x2cc/0x3b0
[<00000000c599b091>] crypto_create_tfm+0x38/0xf0
[<00000000d4516e51>] crypto_spawn_tfm2+0x58/0xa0
[<000000001bab58aa>] cryptd_skcipher_init_tfm+0x1c/0x40
[<0000000006748df3>] crypto_skcipher_init_tfm+0x158/0x1e0
[<0000000017f3270c>] crypto_create_tfm+0x54/0xf0
[<000000006af1de62>] crypto_alloc_tfm+0x88/0x198
[<000000000d8e8c03>] crypto_alloc_skcipher+0x1c/0x28
[<0000000085448a2a>] cryptd_alloc_skcipher+0x5c/0xb0
[<000000003c48c083>] simd_skcipher_init+0x24/0x68
[<0000000006748df3>] crypto_skcipher_init_tfm+0x158/0x1e0
[<0000000017f3270c>] crypto_create_tfm+0x54/0xf0
[<00000000d4516e51>] crypto_spawn_tfm2+0x58/0xa0
[<00000000b5344705>] crypto_cts_init_tfm+0x1c/0x68
[<0000000006748df3>] crypto_skcipher_init_tfm+0x158/0x1e0
[<0000000017f3270c>] crypto_create_tfm+0x54/0xf0
This is caused by tfm = (struct crypto_tfm *)(mem + tfmsize);
that is keept instead of the allocated buffer in mem.
Reference counting is done on alg.
Signed-off-by: Peter Enderborg <peter.enderborg@sony.com>
---
crypto/api.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/crypto/api.c b/crypto/api.c
index ed08cbd5b9d3..1a9cb6852a56 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -21,6 +21,7 @@
#include <linux/string.h>
#include <linux/completion.h>
#include "internal.h"
+#include <linux/kmemleak.h>
LIST_HEAD(crypto_alg_list);
EXPORT_SYMBOL_GPL(crypto_alg_list);
@@ -460,7 +461,7 @@ void *crypto_create_tfm_node(struct crypto_alg *alg,
if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm)))
goto cra_init_failed;
-
+ kmemleak_not_leak(mem);
goto out;
cra_init_failed:
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: Mark tfm buffer as non leak.
2020-09-03 13:40 [PATCH] crypto: Mark tfm buffer as non leak Peter Enderborg
@ 2020-09-04 7:17 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2020-09-04 7:17 UTC (permalink / raw)
To: Peter Enderborg; +Cc: linux-crypto, linux-kernel, davem, peter.enderborg
Peter Enderborg <peter.enderborg@sony.com> wrote:
>
> This is caused by tfm = (struct crypto_tfm *)(mem + tfmsize);
> that is keept instead of the allocated buffer in mem.
> Reference counting is done on alg.
I don't understand why this is necessary. We end up returning
mem in crypto_create_tfm_node and that is the primary means of
getting to the object.
The tfm pointer is just an internal thing. So why do we have
to mark mem as not a leak?
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-04 7:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 13:40 [PATCH] crypto: Mark tfm buffer as non leak Peter Enderborg
2020-09-04 7:17 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).