[PATCH 2/2] KEYS: Fix asym key overflow in keyctl_pkey_verify()

From: Jarkko Sakkinen

Date: Mon Nov 23 2026 - 16:20:28 EST


While verifying a variable-length signature shorter than info.max_sig_size,
memdup_user() reads past the end of the caller's _in2 and passes trailing
bytes to ->asym_verify_signature().

Set params->in2_len to uparams.in2_len in the KEYCTL_PKEY_VERIFY case.

Cc: stable@xxxxxxxxxxxxxxx # v7.2+
Closes: https://sashiko.dev/#/bug/linux-dd9ad2ca-a846-4d0d-89d6-aa262ffd40f1
Fixes: cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
---
security/keys/keyctl_pkey.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/keys/keyctl_pkey.c b/security/keys/keyctl_pkey.c
index b5f82804b5ad..662226576954 100644
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -176,7 +176,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
goto out_up_key_sem;
}

- params->out_len = info.max_sig_size;
+ params->in2_len = uparams.in2_len;
break;
default:
ret = -EOPNOTSUPP;
--
2.47.3