Skip to contentSkip to conversation

KEYS: trusted: return -EEXIST when refusing to update existing key

PATCH New James Bottomley 1 participant 1 message Dec 21, 2022

Subsystems (3)
lore
Share & tools
lore

James Bottomley

author maintainer
#0 lore raw

PATCH 1/1 KEYS: trusted: return -EEXIST when refusing to update existing key

All other key types return -EEXIST when refusing to update an existing key, but trusted keys return -EINVAL, which is confusing to users who can't figure out what the invalid argument is. Fix by returning -EEXIST if the key exists and we can't update it.

Fixes d00a1c72f7f4 ("keys: add new trusted key-type")
---
 security/keys/trusted-keys/trusted_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/trusted-keys/trusted_core.c +1 -1
index c6fc50d67214..8dcd84137035 100644
@@ -254,7 +254,7 @@ static int trusted_update(struct key *key, struct key_preparsed_payload *prep)
 	datablob[datalen] = '\0';
 	ret = datablob_parse(&datablob, new_p);
 	if (ret != Opt_update) {
-		ret = -EINVAL;
+		ret = -EEXIST;
 		kfree_sensitive(new_p);
 		goto out;
 	}
Signature · 1 line
2.35.3