Skip to contentSkip to conversation

Keys: Fix permissions check for update vs add

PATCH New David Howells 1 participant 1 message Nov 30, 2005

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 Keys: Fix permissions check for update vs add

The attached patch permits add_key() to once again update a matching key rather than adding a new one if a matching key already exists in the target keyring.

This bug causes add_key() to always add a new key, displacing the old from the target keyring.

---
warthog>diffstat -p1 keys-permfix-2615rc1.diff

 security/keys/keyring.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
security/keys/keyring.c +1 -1
diff -uNr linux-2.6.15-rc1-keys-reqkey/security/keys/keyring.c linux-2.6.15-rc1-keys-permfix/security/keys/keyring.c
@@ -526,7 +526,7 @@
 			    (!key->type->match ||
 			     key->type->match(key, description)) &&
 			    key_permission(make_key_ref(key, possessed),
-					   perm) < 0 &&
+					   perm) == 0 &&
 			    !test_bit(KEY_FLAG_REVOKED, &key->flags)
 			    )
 				goto found;