浏览代码

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>
David Howells 15 年之前
父节点
当前提交
1e456a1243
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      security/keys/request_key.c

+ 2 - 0
security/keys/request_key.c

@@ -537,6 +537,8 @@ int wait_for_key_construction(struct key *key, bool intr)
 			  intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
 			  intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
 	if (ret < 0)
 	if (ret < 0)
 		return ret;
 		return ret;
+	if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
+		return -ENOKEY;
 	return key_validate(key);
 	return key_validate(key);
 }
 }
 EXPORT_SYMBOL(wait_for_key_construction);
 EXPORT_SYMBOL(wait_for_key_construction);