Skip to content

Commit 1e456a1

Browse files
dhowellstorvalds
authored andcommitted
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. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent fc1caf6 commit 1e456a1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎security/keys/request_key.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ int wait_for_key_construction(struct key *key, bool intr)
537537
intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
538538
if (ret < 0)
539539
return ret;
540+
if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
541+
return -ENOKEY;
540542
return key_validate(key);
541543
}
542544
EXPORT_SYMBOL(wait_for_key_construction);

0 commit comments

Comments
 (0)