소스 검색

[PATCH] Keys: Fix permissions check for update vs add

Permit 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.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
David Howells 19 년 전
부모
커밋
db1d1d57e9
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      security/keys/keyring.c

+ 1 - 1
security/keys/keyring.c

@@ -526,7 +526,7 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref,
 			    (!key->type->match ||
 			    (!key->type->match ||
 			     key->type->match(key, description)) &&
 			     key->type->match(key, description)) &&
 			    key_permission(make_key_ref(key, possessed),
 			    key_permission(make_key_ref(key, possessed),
-					   perm) < 0 &&
+					   perm) == 0 &&
 			    !test_bit(KEY_FLAG_REVOKED, &key->flags)
 			    !test_bit(KEY_FLAG_REVOKED, &key->flags)
 			    )
 			    )
 				goto found;
 				goto found;