Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706493 > unrolled thread

kexec_file: use crypto_free_shash to free memory

Started byPan Bian <bianpan2016@163.com>
First post2017-08-08 14:40 +0200
Last post2017-08-08 20:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  kexec_file: use crypto_free_shash to free memory Pan Bian <bianpan2016@163.com> - 2017-08-08 14:40 +0200
    Re: kexec_file: use crypto_free_shash to free memory ebiederm@xmission.com (Eric W. Biederman) - 2017-08-08 20:20 +0200

#1706493 — kexec_file: use crypto_free_shash to free memory

FromPan Bian <bianpan2016@163.com>
Date2017-08-08 14:40 +0200
Subjectkexec_file: use crypto_free_shash to free memory
Message-ID<ucbXI-8or-21@gated-at.bofh.it>
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.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 kernel/kexec_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 9f48f44..94eeb38 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -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;
 }
-- 
1.9.1

[toc] | [next] | [standalone]


#1706793

Fromebiederm@xmission.com (Eric W. Biederman)
Date2017-08-08 20:20 +0200
Message-ID<uchgJ-3Du-5@gated-at.bofh.it>
In reply to#1706493
Pan Bian <bianpan2016@163.com> writes:

> 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.

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

> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  kernel/kexec_file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> index 9f48f44..94eeb38 100644
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c
> @@ -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;
>  }

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web