Skip to contentSkip to conversation

keys: Fix unreachable code

PATCH New David Howells 1 participant 2 messages Dec 17, 2012

Subsystems (2)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 2/2 KEYS: Use keyring_alloc() to create module signing keyring

In reply to David Howells

Use keyring_alloc() to create special keyrings now that it has a permissions parameter rather than using key_alloc() + key_instantiate_and_link().

---

 kernel/modsign_pubkey.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
kernel/modsign_pubkey.c +6 -9
index 767e559..524a56f 100644
@@ -40,18 +40,15 @@ static __init int module_verify_init(void)
 {
 	pr_notice("Initialise module verification\n");
 
-	modsign_keyring = key_alloc(&key_type_keyring, ".module_sign",
-				    KUIDT_INIT(0), KGIDT_INIT(0),
-				    current_cred(),
-				    (KEY_POS_ALL & ~KEY_POS_SETATTR) |
-				    KEY_USR_VIEW | KEY_USR_READ,
-				    KEY_ALLOC_NOT_IN_QUOTA);
+	modsign_keyring = keyring_alloc(".module_sign",
+					KUIDT_INIT(0), KGIDT_INIT(0),
+					current_cred(),
+					((KEY_POS_ALL & ~KEY_POS_SETATTR) |
+					 KEY_USR_VIEW | KEY_USR_READ),
+					KEY_ALLOC_NOT_IN_QUOTA, NULL);
 	if (IS_ERR(modsign_keyring))
 		panic("Can't allocate module signing keyring\n");
 
-	if (key_instantiate_and_link(modsign_keyring, NULL, 0, NULL, NULL) < 0)
-		panic("Can't instantiate module signing keyring\n");
-
 	return 0;
 }
 

David Howells

author maintainer
#0 lore raw

PATCH 1/2 keys: Fix unreachable code

From: Alan Cox <[email protected]>

We set ret to NULL then test it. Remove the bogus test

---

 security/keys/process_keys.c |    2 --
 1 file changed, 2 deletions(-)
security/keys/process_keys.c +0 -2
index 58dfe08..20e4bf5 100644
@@ -367,8 +367,6 @@ key_ref_t search_my_process_keyrings(struct key_type *type,
 
 		switch (PTR_ERR(key_ref)) {
 		case -EAGAIN: /* no key */
-			if (ret)
-				break;
 		case -ENOKEY: /* negative key */
 			ret = key_ref;
 			break;