kexec_file: use crypto_free_shash to free memory
Subsystems (3)
In function kexec_calculate_store_digests(), kfree() is used to free memory allocated by crypto_alloc_shash(). It is better to use function crypto_free_shash(), which also zeroizes the memory to be freed.
--- kernel/kexec_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kexec_file.c +1 -1
@@ -627,7 +627,7 @@ static int kexec_calculate_store_digests(struct kimage *image) out_free_desc:kfree (desc); out_free_tfm: -kfree (tfm); +crypto_free_shash (tfm); out:return ret; }
Signature · 8 lines
1.9.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 3 lines · Pan Bian
In function
kexec_calculate_store_digests(),kfree()is used to free memory allocated bycrypto_alloc_shash(). It is better to use functioncrypto_free_shash(), which also zeroizes the memory to be freed.
Why is it important to zero memory? There is nothing sensitive being stored or hashed. The hash is used for integrity checking purposes.
If the argument is that kfree is simply the wrong frunction for freeing something allocating with crypto_alloc_shash() I can believe that. In which case that sounds like something that needs to be fixed. But I am concerned that wasn't your argument and you are talking about something that appears to be completely irrelevant.
Eric
Quoted 18 lines
Signed-off-by Pan Bian <[email protected]>--- kernel/kexec_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/kexec_file.c +1
-1@@ -627,7 +627,7 @@ static int kexec_calculate_store_digests(struct kimage *image) out_free_desc:kfree (desc); out_free_tfm: -kfree (tfm); +crypto_free_shash (tfm); out:return ret; }