Skip to content

Commit 70b62c2

Browse files
committed
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>
1 parent d8e9bbd commit 70b62c2

File tree

4 files changed

+8
-45
lines changed

4 files changed

+8
-45
lines changed

include/linux/lsm_hooks.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,10 +2095,5 @@ extern void __init yama_add_hooks(void);
20952095
#else
20962096
static inline void __init yama_add_hooks(void) { }
20972097
#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
21032098

21042099
#endif /* ! __LINUX_LSM_HOOKS_H */

security/Kconfig

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -239,46 +239,9 @@ source "security/yama/Kconfig"
239239

240240
source "security/integrity/Kconfig"
241241

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-
279242
config LSM
280243
string "Ordered list of enabled LSMs"
281-
default "integrity"
244+
default "loadpin,integrity,selinux,smack,tomoyo,apparmor"
282245
help
283246
A comma-separated list of LSMs, in initialization order.
284247
Any LSMs left off this list will be ignored. This can be

security/loadpin/loadpin.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,19 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = {
187187
LSM_HOOK_INIT(kernel_load_data, loadpin_load_data),
188188
};
189189

190-
void __init loadpin_add_hooks(void)
190+
static int __init loadpin_init(void)
191191
{
192192
pr_info("ready to pin (currently %senforcing)\n",
193193
enforce ? "" : "not ");
194194
security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
195+
return 0;
195196
}
196197

198+
DEFINE_LSM(loadpin) = {
199+
.name = "loadpin",
200+
.init = loadpin_init,
201+
};
202+
197203
/* Should not be mutable after boot, so not listed in sysfs (perm == 0). */
198204
module_param(enforce, int, 0);
199205
MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning");

security/security.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ int __init security_init(void)
275275
*/
276276
capability_add_hooks();
277277
yama_add_hooks();
278-
loadpin_add_hooks();
279278

280279
/* Load LSMs in specified order. */
281280
ordered_lsm_init();

0 commit comments

Comments
 (0)