* [PATCH 0/2] security/keys: replace BUG() in unreachable default cases
@ 2026-06-13 13:04 Mohammed EL Kadiri
2026-06-13 13:04 ` [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL Mohammed EL Kadiri
2026-06-13 13:04 ` [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Mohammed EL Kadiri
0 siblings, 2 replies; 5+ messages in thread
From: Mohammed EL Kadiri @ 2026-06-13 13:04 UTC (permalink / raw)
To: jarkko, dhowells
Cc: paul, jmorris, serge, kees, keyrings, linux-security-module,
linux-kernel, linux-hardening, Mohammed EL Kadiri
Replace BUG() in two switch default cases with proper error
returns.
Mohammed EL Kadiri (2):
keys: request_key: replace BUG with return -EINVAL
keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP
security/keys/keyctl_pkey.c | 5 +++--
security/keys/request_key.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL
2026-06-13 13:04 [PATCH 0/2] security/keys: replace BUG() in unreachable default cases Mohammed EL Kadiri
@ 2026-06-13 13:04 ` Mohammed EL Kadiri
2026-06-15 12:06 ` Jarkko Sakkinen
2026-06-13 13:04 ` [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Mohammed EL Kadiri
1 sibling, 1 reply; 5+ messages in thread
From: Mohammed EL Kadiri @ 2026-06-13 13:04 UTC (permalink / raw)
To: jarkko, dhowells
Cc: paul, jmorris, serge, kees, keyrings, linux-security-module,
linux-kernel, linux-hardening, Mohammed EL Kadiri
Replace BUG() in construct_get_dest_keyring() default case
with return -EINVAL to handle the unimplemented group keyring
destination gracefully.
Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
---
security/keys/request_key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index a7673ad86d18..fa2bb9f2f538 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -332,7 +332,7 @@ static int construct_get_dest_keyring(struct key **_dest_keyring)
case KEY_REQKEY_DEFL_GROUP_KEYRING:
default:
- BUG();
+ return -EINVAL;
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL
2026-06-13 13:04 ` [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL Mohammed EL Kadiri
@ 2026-06-15 12:06 ` Jarkko Sakkinen
0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2026-06-15 12:06 UTC (permalink / raw)
To: Mohammed EL Kadiri
Cc: dhowells, paul, jmorris, serge, kees, keyrings,
linux-security-module, linux-kernel, linux-hardening
On Sat, Jun 13, 2026 at 02:04:07PM +0100, Mohammed EL Kadiri wrote:
> Replace BUG() in construct_get_dest_keyring() default case
> with return -EINVAL to handle the unimplemented group keyring
> destination gracefully.
>
> Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
> ---
> security/keys/request_key.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/keys/request_key.c b/security/keys/request_key.c
> index a7673ad86d18..fa2bb9f2f538 100644
> --- a/security/keys/request_key.c
> +++ b/security/keys/request_key.c
> @@ -332,7 +332,7 @@ static int construct_get_dest_keyring(struct key **_dest_keyring)
>
> case KEY_REQKEY_DEFL_GROUP_KEYRING:
> default:
> - BUG();
> + return -EINVAL;
> }
>
> /*
> --
> 2.43.0
>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP
2026-06-13 13:04 [PATCH 0/2] security/keys: replace BUG() in unreachable default cases Mohammed EL Kadiri
2026-06-13 13:04 ` [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL Mohammed EL Kadiri
@ 2026-06-13 13:04 ` Mohammed EL Kadiri
2026-06-15 12:06 ` Jarkko Sakkinen
1 sibling, 1 reply; 5+ messages in thread
From: Mohammed EL Kadiri @ 2026-06-13 13:04 UTC (permalink / raw)
To: jarkko, dhowells
Cc: paul, jmorris, serge, kees, keyrings, linux-security-module,
linux-kernel, linux-hardening, Mohammed EL Kadiri
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@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP
2026-06-13 13:04 ` [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Mohammed EL Kadiri
@ 2026-06-15 12:06 ` Jarkko Sakkinen
0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2026-06-15 12:06 UTC (permalink / raw)
To: Mohammed EL Kadiri
Cc: dhowells, paul, jmorris, serge, kees, keyrings,
linux-security-module, linux-kernel, linux-hardening
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@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@kernel.org>
Thank you.
BR, Jarkko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-15 12:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-13 13:04 [PATCH 0/2] security/keys: replace BUG() in unreachable default cases Mohammed EL Kadiri
2026-06-13 13:04 ` [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL Mohammed EL Kadiri
2026-06-15 12:06 ` Jarkko Sakkinen
2026-06-13 13:04 ` [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Mohammed EL Kadiri
2026-06-15 12:06 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox