Skip to contentSkip to conversation

KEYS: request_key() should return -ENOKEY if the constructed key is negative

PATCH New David Howells 1 participant 1 message Aug 6, 2010

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 KEYS: request_key() should return -ENOKEY if the constructed key is negative

request_key() should return -ENOKEY if the key it constructs has been negatively instantiated.

Without this, request_key() can return an unusable key to its caller, and if the caller then does key_validate() that won't catch the problem.

---

 security/keys/request_key.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
security/keys/request_key.c +2 -0
index 0d26f68..0088dd8 100644
@@ -537,6 +537,8 @@ int wait_for_key_construction(struct key *key, bool intr)
 			  intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
 	if (ret < 0)
 		return ret;
+	if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
+		return -ENOKEY;
 	return key_validate(key);
 }
 EXPORT_SYMBOL(wait_for_key_construction);