summaryrefslogtreecommitdiffstats
path: root/security/security.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-09-19 22:57:06 -0400
committerKees Cook <keescook@chromium.org>2019-01-08 16:18:43 -0500
commit14bd99c821f7ace0e8110a1bfdfaa27e1788e20f (patch)
treea5feee1ff6b832eaffef89d1bde995e0574723e2 /security/security.c
parent7e611486d905f435faf80969deed68a615019e6b (diff)
LSM: Separate idea of "major" LSM from "exclusive" LSM
In order to both support old "security=" Legacy Major LSM selection, and handling real exclusivity, this creates LSM_FLAG_EXCLUSIVE and updates the selection logic to handle them. Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security/security.c')
-rw-r--r--security/security.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/security/security.c b/security/security.c
index 88de6b073246..a8dd7defe30a 100644
--- a/security/security.c
+++ b/security/security.c
@@ -49,6 +49,7 @@ static __initconst const char * const builtin_lsm_order = CONFIG_LSM;
49 49
50/* Ordered list of LSMs to initialize. */ 50/* Ordered list of LSMs to initialize. */
51static __initdata struct lsm_info **ordered_lsms; 51static __initdata struct lsm_info **ordered_lsms;
52static __initdata struct lsm_info *exclusive;
52 53
53static __initdata bool debug; 54static __initdata bool debug;
54#define init_debug(...) \ 55#define init_debug(...) \
@@ -129,6 +130,12 @@ static bool __init lsm_allowed(struct lsm_info *lsm)
129 if (!is_enabled(lsm)) 130 if (!is_enabled(lsm))
130 return false; 131 return false;
131 132
133 /* Not allowed if another exclusive LSM already initialized. */
134 if ((lsm->flags & LSM_FLAG_EXCLUSIVE) && exclusive) {
135 init_debug("exclusive disabled: %s\n", lsm->name);
136 return false;
137 }
138
132 return true; 139 return true;
133} 140}
134 141
@@ -144,6 +151,11 @@ static void __init maybe_initialize_lsm(struct lsm_info *lsm)
144 if (enabled) { 151 if (enabled) {
145 int ret; 152 int ret;
146 153
154 if ((lsm->flags & LSM_FLAG_EXCLUSIVE) && !exclusive) {
155 exclusive = lsm;
156 init_debug("exclusive chosen: %s\n", lsm->name);
157 }
158
147 init_debug("initializing %s\n", lsm->name); 159 init_debug("initializing %s\n", lsm->name);
148 ret = lsm->init(); 160 ret = lsm->init();
149 WARN(ret, "%s failed to initialize: %d\n", lsm->name, ret); 161 WARN(ret, "%s failed to initialize: %d\n", lsm->name, ret);