diff options
author | Kees Cook <keescook@chromium.org> | 2018-09-14 18:26:37 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2019-01-08 16:18:43 -0500 |
commit | 70b62c25665f636c9f6c700b26af7df296b0887e (patch) | |
tree | 03986a41ef6ecdf30b444124c4ef525365cad3bc | |
parent | d8e9bbd4fa7f654bd877a312fc4104c6e5e5c6ca (diff) |
LoadPin: Initialize as ordered LSM
This converts LoadPin from being a direct "minor" LSM into an ordered LSM.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
-rw-r--r-- | include/linux/lsm_hooks.h | 5 | ||||
-rw-r--r-- | security/Kconfig | 39 | ||||
-rw-r--r-- | security/loadpin/loadpin.c | 8 | ||||
-rw-r--r-- | security/security.c | 1 |
4 files changed, 8 insertions, 45 deletions
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index c3843b33da9e..fb1a653ccfcb 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h | |||
@@ -2095,10 +2095,5 @@ extern void __init yama_add_hooks(void); | |||
2095 | #else | 2095 | #else |
2096 | static inline void __init yama_add_hooks(void) { } | 2096 | static inline void __init yama_add_hooks(void) { } |
2097 | #endif | 2097 | #endif |
2098 | #ifdef CONFIG_SECURITY_LOADPIN | ||
2099 | void __init loadpin_add_hooks(void); | ||
2100 | #else | ||
2101 | static inline void loadpin_add_hooks(void) { }; | ||
2102 | #endif | ||
2103 | 2098 | ||
2104 | #endif /* ! __LINUX_LSM_HOOKS_H */ | 2099 | #endif /* ! __LINUX_LSM_HOOKS_H */ |
diff --git a/security/Kconfig b/security/Kconfig index cedf69e8a22c..2cd737ba7660 100644 --- a/security/Kconfig +++ b/security/Kconfig | |||
@@ -239,46 +239,9 @@ source "security/yama/Kconfig" | |||
239 | 239 | ||
240 | source "security/integrity/Kconfig" | 240 | source "security/integrity/Kconfig" |
241 | 241 | ||
242 | choice | ||
243 | prompt "Default security module" | ||
244 | default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX | ||
245 | default DEFAULT_SECURITY_SMACK if SECURITY_SMACK | ||
246 | default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO | ||
247 | default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR | ||
248 | default DEFAULT_SECURITY_DAC | ||
249 | |||
250 | help | ||
251 | Select the security module that will be used by default if the | ||
252 | kernel parameter security= is not specified. | ||
253 | |||
254 | config DEFAULT_SECURITY_SELINUX | ||
255 | bool "SELinux" if SECURITY_SELINUX=y | ||
256 | |||
257 | config DEFAULT_SECURITY_SMACK | ||
258 | bool "Simplified Mandatory Access Control" if SECURITY_SMACK=y | ||
259 | |||
260 | config DEFAULT_SECURITY_TOMOYO | ||
261 | bool "TOMOYO" if SECURITY_TOMOYO=y | ||
262 | |||
263 | config DEFAULT_SECURITY_APPARMOR | ||
264 | bool "AppArmor" if SECURITY_APPARMOR=y | ||
265 | |||
266 | config DEFAULT_SECURITY_DAC | ||
267 | bool "Unix Discretionary Access Controls" | ||
268 | |||
269 | endchoice | ||
270 | |||
271 | config DEFAULT_SECURITY | ||
272 | string | ||
273 | default "selinux" if DEFAULT_SECURITY_SELINUX | ||
274 | default "smack" if DEFAULT_SECURITY_SMACK | ||
275 | default "tomoyo" if DEFAULT_SECURITY_TOMOYO | ||
276 | default "apparmor" if DEFAULT_SECURITY_APPARMOR | ||
277 | default "" if DEFAULT_SECURITY_DAC | ||
278 | |||
279 | config LSM | 242 | config LSM |
280 | string "Ordered list of enabled LSMs" | 243 | string "Ordered list of enabled LSMs" |
281 | default "integrity" | 244 | default "loadpin,integrity,selinux,smack,tomoyo,apparmor" |
282 | help | 245 | help |
283 | A comma-separated list of LSMs, in initialization order. | 246 | A comma-separated list of LSMs, in initialization order. |
284 | Any LSMs left off this list will be ignored. This can be | 247 | Any LSMs left off this list will be ignored. This can be |
diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c index 48f39631b370..055fb0a64169 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c | |||
@@ -187,13 +187,19 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = { | |||
187 | LSM_HOOK_INIT(kernel_load_data, loadpin_load_data), | 187 | LSM_HOOK_INIT(kernel_load_data, loadpin_load_data), |
188 | }; | 188 | }; |
189 | 189 | ||
190 | void __init loadpin_add_hooks(void) | 190 | static int __init loadpin_init(void) |
191 | { | 191 | { |
192 | pr_info("ready to pin (currently %senforcing)\n", | 192 | pr_info("ready to pin (currently %senforcing)\n", |
193 | enforce ? "" : "not "); | 193 | enforce ? "" : "not "); |
194 | security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); | 194 | security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); |
195 | return 0; | ||
195 | } | 196 | } |
196 | 197 | ||
198 | DEFINE_LSM(loadpin) = { | ||
199 | .name = "loadpin", | ||
200 | .init = loadpin_init, | ||
201 | }; | ||
202 | |||
197 | /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ | 203 | /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ |
198 | module_param(enforce, int, 0); | 204 | module_param(enforce, int, 0); |
199 | MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning"); | 205 | MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning"); |
diff --git a/security/security.c b/security/security.c index 46c5b0fa515e..b8d75f5a948d 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -275,7 +275,6 @@ int __init security_init(void) | |||
275 | */ | 275 | */ |
276 | capability_add_hooks(); | 276 | capability_add_hooks(); |
277 | yama_add_hooks(); | 277 | yama_add_hooks(); |
278 | loadpin_add_hooks(); | ||
279 | 278 | ||
280 | /* Load LSMs in specified order. */ | 279 | /* Load LSMs in specified order. */ |
281 | ordered_lsm_init(); | 280 | ordered_lsm_init(); |