Skip to contentSkip to conversation

KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()

PATCH Applied Guicai Ma 3 participants 3 messages Nov 24

Subsystems (2)
lore
Share & tools
lore

Guicai Ma

author
#0 lore raw

PATCH 1/1 KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()

keyctl_pkey_e_d_s() frees the temporary 'in' and 'out' buffers with kfree(). For encrypt, decrypt and sign operations these buffers hold plaintext or other sensitive data.

Free them with kfree_sensitive() instead.

Fixes 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
---
 security/keys/keyctl_pkey.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/keyctl_pkey.c +2 -2
index e7121523b9c9..8d2c2b65f50b 100644
@@ -314,9 +314,9 @@ long keyctl_pkey_e_d_s(int op,
 		ret = -EFAULT;
 
 error_out:
-	kfree(out);
+	kfree_sensitive(out);
 error_in:
-	kfree(in);
+	kfree_sensitive(in);
 error_params:
 	keyctl_pkey_params_free(&params);
 	return ret;
Signature · 1 line
2.47.3
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

keyctl_pkey_e_d_s() frees the temporary 'in' and 'out' buffers with kfree(). For encrypt, decrypt and sign operations these buffers hold plaintext or other sensitive data.

Free them with kfree_sensitive() instead.

Fixes 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Applied
#2 lore raw
In reply to Guicai Ma
Quoted 32 lines · Guicai Ma

keyctl_pkey_e_d_s() frees the temporary 'in' and 'out' buffers with kfree(). For encrypt, decrypt and sign operations these buffers hold plaintext or other sensitive data.

Free them with kfree_sensitive() instead.

Fixes 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
---
 security/keys/keyctl_pkey.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/keyctl_pkey.c +2 -2
index e7121523b9c9..8d2c2b65f50b 100644
@@ -314,9 +314,9 @@ long keyctl_pkey_e_d_s(int op,
 		ret = -EFAULT;
 
 error_out:
-	kfree(out);
+	kfree_sensitive(out);
 error_in:
-	kfree(in);
+	kfree_sensitive(in);
 error_params:
 	keyctl_pkey_params_free(&params);
 	return ret;
Signature · 1 line
2.47.3

Thanks applied.

Br, Jarkko