[PATCH] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()

From: Guicai Ma

Date: Tue Nov 24 2026 - 00:29:19 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Guicai Ma <maguicai@xxxxxxxxxx>
---
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(&params);
return ret;
--
2.47.3