* [PATCH] net: esp4: Fix double free on esp4 functions
@ 2019-01-30 21:35 Ramin Farajpour Cami
2019-01-30 21:53 ` David Miller
2019-01-30 23:07 ` Eric Dumazet
0 siblings, 2 replies; 4+ messages in thread
From: Ramin Farajpour Cami @ 2019-01-30 21:35 UTC (permalink / raw)
To: davem; +Cc: herbert, steffen.klassert, netdev, Ramin Farajpour Cami
key/tmp is being kfree'd twice,once in the "aalg_desc->uinfo.auth.icv_fullbits / 8 != crypto_aead_authsize(aead)" call
to "free_key",twice When "crypto_aead_setauthsize(aead, x->aalg->alg_trunc_len / 8)" fails call to again "free_key",
Signed-off-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
---
net/ipv4/esp4.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 5459f41fc26f..5a66e47641b0 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -467,6 +467,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
error_free:
kfree(tmp);
+ tmp = NULL;
error:
return err;
}
@@ -959,7 +960,7 @@ static int esp_init_authenc(struct xfrm_state *x)
free_key:
kfree(key);
-
+ key = NULL;
error:
return err;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: esp4: Fix double free on esp4 functions
2019-01-30 21:35 [PATCH] net: esp4: Fix double free on esp4 functions Ramin Farajpour Cami
@ 2019-01-30 21:53 ` David Miller
2019-01-30 23:07 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-01-30 21:53 UTC (permalink / raw)
To: ramin.blackhat; +Cc: herbert, steffen.klassert, netdev
From: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
Date: Wed, 30 Jan 2019 21:35:42 +0000
> key/tmp is being kfree'd twice,once in the "aalg_desc->uinfo.auth.icv_fullbits / 8 != crypto_aead_authsize(aead)" call
> to "free_key",twice When "crypto_aead_setauthsize(aead, x->aalg->alg_trunc_len / 8)" fails call to again "free_key",
>
> Signed-off-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
> ---
> net/ipv4/esp4.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
> index 5459f41fc26f..5a66e47641b0 100644
> --- a/net/ipv4/esp4.c
> +++ b/net/ipv4/esp4.c
> @@ -467,6 +467,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
>
> error_free:
> kfree(tmp);
> + tmp = NULL;
> error:
> return err;
> }
This makes no sense at all, the function returns right after the kfree() and
tmp is never referenced again!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: esp4: Fix double free on esp4 functions
2019-01-30 21:35 [PATCH] net: esp4: Fix double free on esp4 functions Ramin Farajpour Cami
2019-01-30 21:53 ` David Miller
@ 2019-01-30 23:07 ` Eric Dumazet
[not found] ` <CAKEzZ8zyhvJ1Fr6UDOxVqBnUz73xPSLwfnoM4FFGf6wHSTU=Jg@mail.gmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2019-01-30 23:07 UTC (permalink / raw)
To: Ramin Farajpour Cami, davem; +Cc: herbert, steffen.klassert, netdev
On 01/30/2019 01:35 PM, Ramin Farajpour Cami wrote:
> key/tmp is being kfree'd twice,once in the "aalg_desc->uinfo.auth.icv_fullbits / 8 != crypto_aead_authsize(aead)" call
> to "free_key",twice When "crypto_aead_setauthsize(aead, x->aalg->alg_trunc_len / 8)" fails call to again "free_key",
>
> Signed-off-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
> ---
> net/ipv4/esp4.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
> index 5459f41fc26f..5a66e47641b0 100644
> --- a/net/ipv4/esp4.c
> +++ b/net/ipv4/esp4.c
> @@ -467,6 +467,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
>
> error_free:
> kfree(tmp);
> + tmp = NULL;
Clearing tmp right before a "return err;" has no effect at all.
> error:
> return err;
> }
> @@ -959,7 +960,7 @@ static int esp_init_authenc(struct xfrm_state *x)
>
> free_key:
> kfree(key);
> -
> + key = NULL;
Same here, this is essentially dead code.
> error:
> return err;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: esp4: Fix double free on esp4 functions
[not found] ` <CAKEzZ8zyhvJ1Fr6UDOxVqBnUz73xPSLwfnoM4FFGf6wHSTU=Jg@mail.gmail.com>
@ 2019-01-31 7:27 ` Steffen Klassert
0 siblings, 0 replies; 4+ messages in thread
From: Steffen Klassert @ 2019-01-31 7:27 UTC (permalink / raw)
To: Ramin Farajpour Cami; +Cc: Eric Dumazet, davem, Herbert Xu, netdev
On Thu, Jan 31, 2019 at 06:32:07AM +0000, Ramin Farajpour Cami wrote:
> Hi Eric,
>
> I going to for avoid double free of resource identifiers we should set
> variables initialized in "tmp/key" to NULL if an error occurred int the
> "esp_init_authenc()" and "esp_output_tail()" attempts to free the memory
> again.my means like this patch c7055fd15ff46d92eb0dd1c16a4fe010d58224c8
> <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c7055fd15ff46d92eb0dd1c16a4fe010d58224c8>
There is a big difference between the above-noted patch and
your patch. You really have to understand the code you are
trying to change.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-31 7:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 21:35 [PATCH] net: esp4: Fix double free on esp4 functions Ramin Farajpour Cami
2019-01-30 21:53 ` David Miller
2019-01-30 23:07 ` Eric Dumazet
[not found] ` <CAKEzZ8zyhvJ1Fr6UDOxVqBnUz73xPSLwfnoM4FFGf6wHSTU=Jg@mail.gmail.com>
2019-01-31 7:27 ` Steffen Klassert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.