security/keys: replace BUG() in unreachable default cases
Subsystems (2)
cover security/keys: replace BUG() in unreachable default cases
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(-)
Signature · 1 line
2.43.0
PATCH 1/2 keys: request_key: replace BUG with return -EINVAL
Replace BUG() in construct_get_dest_keyring() default case with return -EINVAL to handle the unimplemented group keyring destination gracefully.
--- security/keys/request_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/request_key.c +1 -1
@@ -332,7 +332,7 @@ static int construct_get_dest_keyring(struct key **_dest_keyring)case KEY_REQKEY_DEFL_GROUP_KEYRING :default : -BUG (); +return -EINVAL ; }/*
Signature · 1 line
2.43.0
Re: [PATCH 1/2] keys: request_key: replace BUG with return -EINVAL
Quoted 25 lines · Mohammed EL Kadiri
Replace
BUG()inconstruct_get_dest_keyring()default case with return-EINVALto handle the unimplemented group keyring destination gracefully.Signed-off-by Mohammed EL Kadiri <[email protected]>--- security/keys/request_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)security/keys/request_key.c +1
-1@@ -332,7 +332,7 @@ static int construct_get_dest_keyring(struct key **_dest_keyring)case KEY_REQKEY_DEFL_GROUP_KEYRING :default : -BUG (); +return -EINVAL ; }/* Signature · 1 line
2.43.0
BR, Jarkko
PATCH 2/2 keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP
In reply to Mohammed EL KadiriReplace 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.
--- security/keys/keyctl_pkey.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
security/keys/keyctl_pkey.c +3 -2
@@ -155,7 +155,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_parreturn -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);
Signature · 1 line
2.43.0
Re: [PATCH 2/2] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP
Quoted 35 lines · Mohammed EL Kadiri
Replace two
BUG()calls inkeyctl_pkey_params_get_2()andkeyctl_pkey_e_d_s()default cases with-EOPNOTSUPP, matching the error style already used in these functions.Signed-off-by Mohammed EL Kadiri <[email protected]>--- security/keys/keyctl_pkey.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)security/keys/keyctl_pkey.c +3
-2@@ -155,7 +155,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_parreturn -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);Signature · 1 line
2.43.0
Thank you.
BR, Jarkko