]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
KEYS: request_key() should return -ENOKEY if the constructed key is negative
authorDavid Howells <dhowells@redhat.com>
Fri, 6 Aug 2010 15:08:27 +0000 (16:08 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Aug 2010 16:17:02 +0000 (09:17 -0700)
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.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
security/keys/request_key.c

index 0d26f689bd7726f7d253607a0f5899c00e947fcc..0088dd8bf68a77b29637527733ff0b8985b8ecb7 100644 (file)
@@ -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);