All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jarkko Sakkinen" <jarkko@kernel.org>, keyrings@vger.kernel.org
Cc: linux-security-module@vger.kernel.org,
	"David Howells" <dhowells@redhat.com>,
	"Guicai Ma" <maguicai@kylinos.cn>,
	"James Morris" <jmorris@namei.org>,
	"Paul Moore" <paul@paul-moore.com>,
	"Serge E. Hallyn" <serge@hallyn.com>
Subject: Re: [PATCH 1/2] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s()
Date: Mon, 23 Nov 2026 21:32:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-230085@kernel.org> (raw)
In-Reply-To: <20261123211959.4102708-2-jarkko@kernel.org>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] KEYS: sensitive plaintext leaked to slab in keyctl_pkey_e_d_s()
  [1]
--

commit e1794f1dd0090bbea27485536c98f990c8a30f19
Author: Guicai Ma <maguicai@kylinos.cn>

KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s()

This commit passes the caller's output buffer length back from
keyctl_pkey_params_get_2() to keyctl_pkey_e_d_s() and returns -EOVERFLOW if
the operation output exceeds it before copying to userspace.

> diff --git a/security/keys/keyctl_pkey.c b/security/keys/keyctl_pkey.c
> index e7121523b9c9a..b5f82804b5ad1 100644
> --- a/security/keys/keyctl_pkey.c
> +++ b/security/keys/keyctl_pkey.c
[ ... ]
> @@ -310,6 +315,10 @@ long keyctl_pkey_e_d_s(int op,
>  	if (ret < 0)
>  		goto error_out;
>  
> +	if (ret > user_out_len) {
> +		ret = -EOVERFLOW;
> +		goto error_out;
> +	}
>  	if (copy_to_user(_out, out, ret) != 0)
>  		ret = -EFAULT;

[Severity: High]
This problem wasn't introduced by this patch, but should the error_out and
error_in paths in keyctl_pkey_e_d_s() use kfree_sensitive() instead of
kfree() [1]?

security/keys/keyctl_pkey.c:keyctl_pkey_e_d_s() {
	...
error_out:
	kfree(out);
error_in:
	kfree(in);
	...
}

Because in and out hold plaintext or other cryptographic payloads for
KEYCTL_PKEY_ENCRYPT, KEYCTL_PKEY_DECRYPT, and KEYCTL_PKEY_SIGN, freeing
them with kfree() leaves sensitive material in the slab cache.

[1] https://sashiko.dev/#/bug/linux-4199b169-0b8d-4055-9a71-6b5b79e38eb3

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123211959.4102708-1-jarkko@kernel.org?part=1

  parent reply	other threads:[~2026-11-23 21:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 21:19 [PATCH 0/2] KEYS: keyctl overflow fixes Jarkko Sakkinen
2026-11-23 21:19 ` [PATCH 1/2] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s() Jarkko Sakkinen
2026-11-23 21:25   ` Jarkko Sakkinen
2026-11-23 21:32   ` sashiko-bot [this message]
2026-11-23 21:19 ` [PATCH 2/2] KEYS: Fix asym key overflow in keyctl_pkey_verify() Jarkko Sakkinen
2026-11-23 21:26   ` Jarkko Sakkinen
2026-11-24  5:25   ` Guicai Ma
2026-11-23 21:32 ` [PATCH 0/2] KEYS: keyctl overflow fixes sashiko-bot

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=sashiko-outbox-230085@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=maguicai@kylinos.cn \
    --cc=paul@paul-moore.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.