Skip to contentSkip to conversation

net: ipv4: Use kfree_sensitive instead of kfree

PATCH Applied Wang Ming 4 participants 4 messages Jul 17, 2023 – Jul 19, 2023

Subsystems (3)
lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH 1/1 net: ipv4: Use kfree_sensitive instead of kfree

key might contain private part of the key, so better use kfree_sensitive to free it.

Fixes 38320c70d282 ("[IPSEC]: Use crypto_aead and authenc in ESP")
---
 net/ipv4/esp4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/esp4.c +1 -1
index ba06ed42e428..2be2d4922557 100644
@@ -1132,7 +1132,7 @@ static int esp_init_authenc(struct xfrm_state *x,
 	err = crypto_aead_setkey(aead, key, keylen);
 
 free_key:
-	kfree(key);
+	kfree_sensitive(key);
 
 error:
 	return err;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Wang Ming

key might contain private part of the key, so better use kfree_sensitive to free it.

Fixes 38320c70d282 ("[IPSEC]: Use crypto_aead and authenc in ESP")
---
  net/ipv4/esp4.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/esp4.c +0 -0
index ba06ed42e428..2be2d4922557 100644

net/ipv4/esp4.c static int esp_init_authenc(struct xfrm_state *x, · line 1138

Quoted 8 lines
net/ipv4/esp4.c +1 -1
@@ -1132,7 +1132,7 @@ static int esp_init_authenc(struct xfrm_state *x,
  	err = crypto_aead_setkey(aead, key, keylen);
 
  free_key:
-	kfree(key);
+	kfree_sensitive(key);
 
  error:
  	return err;

LGTM.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Wang Ming

From: Wang Ming <[email protected]>
Date: Mon, 17 Jul 2023 17:59:19 +0800

Quoted 5 lines

key might contain private part of the key, so better use kfree_sensitive to free it.

Fixes 38320c70d282 ("[IPSEC]: Use crypto_aead and authenc in ESP")
Quoted 19 lines
---
 net/ipv4/esp4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/esp4.c +1 -1
index ba06ed42e428..2be2d4922557 100644
@@ -1132,7 +1132,7 @@ static int esp_init_authenc(struct xfrm_state *x,
 	err = crypto_aead_setkey(aead, key, keylen);
 
 free_key:
-	kfree(key);
+	kfree_sensitive(key);
 
 error:
 	return err;
Signature · 1 line
2.25.1
#3 lore raw
In reply to Wang Ming
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Mon, 17 Jul 2023 17:59:19 +0800 you wrote:

key might contain private part of the key, so better use kfree_sensitive to free it.

Fixes 38320c70d282 ("[IPSEC]: Use crypto_aead and authenc in ESP")
---
 net/ipv4/esp4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [net,v1] net: ipv4: Use kfree_sensitive instead of kfree

    https://git.kernel.org/netdev/net/c/daa751444fd9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html