1e304cc
From 93f27344ac019135dd5ff31a518f1ef2d9e4e4a1 Mon Sep 17 00:00:00 2001
1e304cc
From: David Howells <dhowells@redhat.com>
1e304cc
Date: Mon, 19 Oct 2015 11:33:38 +0100
1e304cc
Subject: [PATCH 2/2] KEYS: Don't permit request_key() to construct a new
1e304cc
 keyring
1e304cc
1e304cc
    If request_key() is used to find a keyring, only do the search part - don't
1e304cc
    do the construction part if the keyring was not found by the search.  We
1e304cc
    don't really want keyrings in the negative instantiated state since the
1e304cc
    rejected/negative instantiation error value in the payload is unioned with
1e304cc
    keyring metadata.
1e304cc
1e304cc
    Signed-off-by: David Howells <dhowells@redhat.com>
1e304cc
---
1e304cc
 security/keys/request_key.c | 3 +++
1e304cc
 1 file changed, 3 insertions(+)
1e304cc
1e304cc
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
1e304cc
index 486ef6fa393b..0d6253124278 100644
1e304cc
--- a/security/keys/request_key.c
1e304cc
+++ b/security/keys/request_key.c
1e304cc
@@ -440,6 +440,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
1e304cc
 
1e304cc
 	kenter("");
1e304cc
 
1e304cc
+	if (ctx->index_key.type == &key_type_keyring)
1e304cc
+		return ERR_PTR(-EPERM);
1e304cc
+	
1e304cc
 	user = key_user_lookup(current_fsuid());
1e304cc
 	if (!user)
1e304cc
 		return ERR_PTR(-ENOMEM);
1e304cc
-- 
1e304cc
2.4.3
1e304cc