From: Jarkko Sakkinen <jarkko@kernel.org>
To: Guicai Ma <maguicai@kylinos.cn>
Cc: David Howells <dhowells@redhat.com>,
keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E . Hallyn" <serge@hallyn.com>
Subject: Re: [PATCH] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()
Date: Tue, 24 Nov 2026 19:18:34 +0200 [thread overview]
Message-ID: <awXG6k1HFYsE2wE5@kernel.org> (raw)
In-Reply-To: <20261124052849.940005-1-maguicai@kylinos.cn>
On Tue, Nov 24, 2026 at 12:28:49AM -0500, Guicai Ma wrote:
> 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@vger.kernel.org
> Signed-off-by: Guicai Ma <maguicai@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
Thanks applied.
Br, Jarkko
prev parent reply other threads:[~2026-11-24 17:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 5:28 [PATCH] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s() Guicai Ma
2026-11-24 17:18 ` Jarkko Sakkinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awXG6k1HFYsE2wE5@kernel.org \
--to=jarkko@kernel.org \
--cc=dhowells@redhat.com \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=maguicai@kylinos.cn \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox