crypto: Mark tfm buffer as non leak.
PATCH 1/1 crypto: Mark tfm buffer as non leak.
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/0xf0This 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.
--- crypto/api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
crypto/api.c +2 -1
@@ -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:
Signature · 1 line
2.17.1
Herbert Xu
maintainerQuoted 4 lines · Peter Enderborg
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,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt