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

Jarkko Sakkinen jarkko at kernel.org
Mon Nov 23 21:26:37 UTC 2026


On Mon, Nov 23, 2026 at 11:19:59PM +0200, Jarkko Sakkinen wrote:
> 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 at vger.kernel.org # 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 at kernel.org>
> ---
>  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
> 

I'll apply this with or without r-by's and/or t-by's but they will be appreciated.

Br, Jarkko



More information about the Linux-security-module-archive mailing list