Skip to contentSkip to conversation

security: clarify that some code is really non-modular

PATCH Applied Paul Gortmaker 3 participants 6 messages Dec 9, 2015 – Feb 18, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover security: clarify that some code is really non-modular

The goal is to ensure that non-modular code doesn't appear modular just by accident. Here we have two more commits to do that and they are of the trivial nature (i.e. no ".remove" functions deleted and no need to block any unbind actions). We just change the registration functions to be the non modular versions and adjust the include headers to match.

Paul Gortmaker (2):
security/keys: make big_key.c explicitly non-modular security/integrity: make ima/ima_mok.c explicitly non-modular

 security/integrity/ima/ima_mok.c |  5 ++---
 security/keys/big_key.c          | 15 +--------------
 2 files changed, 3 insertions(+), 17 deletions(-)

---

Cc David Howells <[email protected]>
Cc James Morris <[email protected]>
Cc "Serge E. Hallyn" <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Dmitry Kasatkin <[email protected]>
Cc James Morris <[email protected]>
Cc "Serge E. Hallyn" <[email protected]>

2.6.1

#1 lore raw

PATCH 1/2 security/keys: make big_key.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

config BIG_KEYS
bool "Large payload keys"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

We also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments.

---
 security/keys/big_key.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
security/keys/big_key.c +1 -14
index 907c1522ee46..c721e398893a 100644
@@ -9,7 +9,6 @@
  * 2 of the Licence, or (at your option) any later version.
  */
 
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/file.h>
@@ -18,8 +17,6 @@
 #include <keys/user-type.h>
 #include <keys/big_key-type.h>
 
-MODULE_LICENSE("GPL");
-
 /*
  * Layout of key payload words.
  */
@@ -212,18 +209,8 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
 	return ret;
 }
 
-/*
- * Module stuff
- */
 static int __init big_key_init(void)
 {
 	return register_key_type(&key_type_big_key);
 }
-
-static void __exit big_key_cleanup(void)
-{
-	unregister_key_type(&key_type_big_key);
-}
-
-module_init(big_key_init);
-module_exit(big_key_cleanup);
+device_initcall(big_key_init);
Signature · 1 line
2.6.1
maintainer Applied
#2 lore raw

Re: [PATCH 1/2] security/keys: make big_key.c explicitly non-modular

Quoted 16 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config BIG_KEYS
bool "Large payload keys"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

We also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments.

Quoted 6 lines

I've applied this patch to my next tree.

David

#3 lore raw

PATCH 2/2 security/integrity: make ima/ima_mok.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

ima/Kconfig:config IMA_MOK_KEYRING
ima/Kconfig: bool "Create IMA machine owner keys (MOK) and blacklist keyrings"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple of traces of modularity so that when reading the driver there is no doubt it really is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

---
 security/integrity/ima/ima_mok.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
security/integrity/ima/ima_mok.c +2 -3
index 8dad9a2b8e47..676885e4320e 100644
@@ -16,7 +16,7 @@
 #include <linux/sched.h>
 #include <linux/cred.h>
 #include <linux/err.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <keys/asymmetric-type.h>
 
 
@@ -52,5 +52,4 @@ __init int ima_mok_init(void)
 	set_bit(KEY_FLAG_KEEP, &ima_blacklist_keyring->flags);
 	return 0;
 }
-
-module_init(ima_mok_init);
+device_initcall(ima_mok_init);
Signature · 1 line
2.6.1
#4 lore raw

Re: [PATCH 2/2] security/integrity: make ima/ima_mok.c explicitly non-modular

Quoted 13 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

ima/Kconfig:config IMA_MOK_KEYRING
ima/Kconfig: bool "Create IMA machine owner keys (MOK) and blacklist keyrings"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple of traces of modularity so that when reading the driver there is no doubt it really is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

Quoted 8 lines

Thanks, this patch is queued to be upstreamed with the original ima_mok keyring patch.

Mimi

Quoted 24 lines
---
 security/integrity/ima/ima_mok.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
security/integrity/ima/ima_mok.c +2 -3
index 8dad9a2b8e47..676885e4320e 100644
@@ -16,7 +16,7 @@
 #include <linux/sched.h>
 #include <linux/cred.h>
 #include <linux/err.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <keys/asymmetric-type.h>
 
 
@@ -52,5 +52,4 @@ __init int ima_mok_init(void)
 	set_bit(KEY_FLAG_KEEP, &ima_blacklist_keyring->flags);
 	return 0;
 }
-
-module_init(ima_mok_init);
+device_initcall(ima_mok_init);