[PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP

Jarkko Sakkinen jarkko at kernel.org
Mon Jun 15 12:06:43 UTC 2026


On Sat, Jun 13, 2026 at 02:04:08PM +0100, Mohammed EL Kadiri wrote:
> Replace two BUG() calls in keyctl_pkey_params_get_2() and
> keyctl_pkey_e_d_s() default cases with -EOPNOTSUPP, matching
> the error style already used in these functions.
> 
> Signed-off-by: Mohammed EL Kadiri <med08elkadiri at gmail.com>
> ---
>  security/keys/keyctl_pkey.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/keyctl_pkey.c b/security/keys/keyctl_pkey.c
> index 97bc27bbf079..6b2821ffeb6c 100644
> --- a/security/keys/keyctl_pkey.c
> +++ b/security/keys/keyctl_pkey.c
> @@ -155,7 +155,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
>  			return -EINVAL;
>  		break;
>  	default:
> -		BUG();
> +		return -EOPNOTSUPP;
>  	}
>  
>  	params->in_len  = uparams.in_len;
> @@ -238,7 +238,8 @@ long keyctl_pkey_e_d_s(int op,
>  		params.op = kernel_pkey_sign;
>  		break;
>  	default:
> -		BUG();
> +		ret = -EOPNOTSUPP;
> +		goto error_params;
>  	}
>  
>  	in = memdup_user(_in, params.in_len);
> -- 
> 2.43.0
> 

Reviewed-by: Jarkko Sakkinen <jarkko at kernel.org>

Thank you.

BR, Jarkko




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