[PATCH] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()
Guicai Ma
maguicai at kylinos.cn
Tue Nov 24 05:28:49 UTC 2026
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.
Closes: https://sashiko.dev/#/bug/linux-4199b169-0b8d-4055-9a71-6b5b79e38eb3
Fixes: 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
Cc: stable at vger.kernel.org
Signed-off-by: Guicai Ma <maguicai at kylinos.cn>
---
security/keys/keyctl_pkey.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/keys/keyctl_pkey.c b/security/keys/keyctl_pkey.c
index e7121523b9c9..8d2c2b65f50b 100644
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -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(¶ms);
return ret;
--
2.47.3
More information about the Linux-security-module-archive
mailing list