From: sashiko-bot@kernel.org
To: "Guicai Ma" <maguicai@kylinos.cn>,
"David Howells" <dhowells@redhat.com>,
"Jarkko Sakkinen" <jarkko@kernel.org>
Cc: "Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E . Hallyn" <serge@hallyn.com>,
"Florian Bauckholt" <florian.bauckholt@cispa.de>,
keyrings@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCH] KEYS: fix userspace buffer overflow in keyctl_pkey_e_d_s()
Date: Fri, 20 Nov 2026 02:36:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-224374@kernel.org> (raw)
In-Reply-To: <20261120022447.789625-1-maguicai@kylinos.cn>
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: in2_len overwritten with max_sig_size in
keyctl_pkey_params_get_2() [1]
--
commit a87f672b96b4f7c3b4eabf969b369139c77f96be
Author: Guicai Ma <maguicai@kylinos.cn>
KEYS: fix userspace buffer overflow in keyctl_pkey_e_d_s()
This commit passes the caller-supplied uparams.out_len back from
keyctl_pkey_params_get_2() to keyctl_pkey_e_d_s() and returns -EOVERFLOW if
the operation output exceeds the userspace buffer size.
> 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
> @@ -113,7 +113,8 @@ static int keyctl_pkey_params_get(key_serial_t id,
> static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_params,
> const char __user *_info,
> int op,
> - struct kernel_pkey_params *params)
> + struct kernel_pkey_params *params,
> + u32 *user_out_len)
> {
> struct keyctl_pkey_params uparams;
> struct kernel_pkey_query info;
> @@ -183,6 +184,8 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
> }
>
> params->in_len = uparams.in_len;
> + if (user_out_len)
> + *user_out_len = uparams.out_len;
>
> switch (op) {
> case KEYCTL_PKEY_VERIFY:
[Severity: High]
This problem wasn't introduced by this patch, but in the
KEYCTL_PKEY_VERIFY case just above this hunk, commit cb481e59ea6c ("KEYS:
fix overflow in keyctl_pkey_params_get_2()") also overwrote params->out_len
(which aliases params->in2_len in struct kernel_pkey_params) with
info.max_sig_size instead of preserving uparams.in2_len [1]:
security/keys/keyctl_pkey.c:keyctl_pkey_params_get_2() {
...
case KEYCTL_PKEY_VERIFY:
if (uparams.in_len > info.max_data_size ||
uparams.in2_len > info.max_sig_size) {
ret = -EINVAL;
goto out_up_key_sem;
}
params->out_len = info.max_sig_size;
break;
...
}
When keyctl_pkey_verify() verifies a variable-length signature shorter than
info.max_sig_size (such as an ASN.1 DER-encoded ECDSA signature), does
memdup_user(_in2, params.in2_len) read past the end of the userspace _in2
buffer and either fail with -EFAULT or pass trailing garbage bytes to
asym_verify_signature()?
Should KEYCTL_PKEY_VERIFY set params->in2_len = uparams.in2_len instead?
[1] https://sashiko.dev/#/bug/linux-dd9ad2ca-a846-4d0d-89d6-aa262ffd40f1
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120022447.789625-1-maguicai@kylinos.cn?part=1
prev parent reply other threads:[~2026-11-20 2:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 2:24 [PATCH] KEYS: fix userspace buffer overflow in keyctl_pkey_e_d_s() Guicai Ma
2026-11-20 2:36 ` sashiko-bot [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=sashiko-outbox-224374@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dhowells@redhat.com \
--cc=florian.bauckholt@cispa.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox