diff options
| author | Casey Schaufler <casey@schaufler-ca.com> | 2018-11-19 21:04:32 -0500 |
|---|---|---|
| committer | Kees Cook <keescook@chromium.org> | 2019-01-08 16:18:43 -0500 |
| commit | c91d8106b370593b4d3dcc0b06282bf39478ae13 (patch) | |
| tree | ab45414d24e44e6aefcb909ecdc50b37d2effec6 | |
| parent | be6ec88f41ba94746f830ba38cc4d08dd5ddbb08 (diff) | |
LSM: Add all exclusive LSMs to ordered initialization
This removes CONFIG_DEFAULT_SECURITY in favor of the explicit ordering
offered by CONFIG_LSM and adds all the exclusive LSMs to the ordered
LSM initialization. The old meaning of CONFIG_DEFAULT_SECURITY is now
captured by which exclusive LSM is listed first in the LSM order. All
LSMs not added to the ordered list are explicitly disabled.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
| -rw-r--r-- | security/security.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/security/security.c b/security/security.c index a8dd7defe30a..2d08a5357bf4 100644 --- a/security/security.c +++ b/security/security.c | |||
| @@ -169,8 +169,6 @@ static void __init ordered_lsm_parse(const char *order, const char *origin) | |||
| 169 | char *sep, *name, *next; | 169 | char *sep, *name, *next; |
| 170 | 170 | ||
| 171 | /* Process "security=", if given. */ | 171 | /* Process "security=", if given. */ |
| 172 | if (!chosen_major_lsm) | ||
| 173 | chosen_major_lsm = CONFIG_DEFAULT_SECURITY; | ||
| 174 | if (chosen_major_lsm) { | 172 | if (chosen_major_lsm) { |
| 175 | struct lsm_info *major; | 173 | struct lsm_info *major; |
| 176 | 174 | ||
| @@ -198,8 +196,7 @@ static void __init ordered_lsm_parse(const char *order, const char *origin) | |||
| 198 | bool found = false; | 196 | bool found = false; |
| 199 | 197 | ||
| 200 | for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { | 198 | for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { |
| 201 | if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0 && | 199 | if (strcmp(lsm->name, name) == 0) { |
| 202 | strcmp(lsm->name, name) == 0) { | ||
| 203 | append_ordered_lsm(lsm, origin); | 200 | append_ordered_lsm(lsm, origin); |
| 204 | found = true; | 201 | found = true; |
| 205 | } | 202 | } |
| @@ -208,6 +205,25 @@ static void __init ordered_lsm_parse(const char *order, const char *origin) | |||
| 208 | if (!found) | 205 | if (!found) |
| 209 | init_debug("%s ignored: %s\n", origin, name); | 206 | init_debug("%s ignored: %s\n", origin, name); |
| 210 | } | 207 | } |
| 208 | |||
| 209 | /* Process "security=", if given. */ | ||
| 210 | if (chosen_major_lsm) { | ||
| 211 | for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { | ||
| 212 | if (exists_ordered_lsm(lsm)) | ||
| 213 | continue; | ||
| 214 | if (strcmp(lsm->name, chosen_major_lsm) == 0) | ||
| 215 | append_ordered_lsm(lsm, "security="); | ||
| 216 | } | ||
| 217 | } | ||
| 218 | |||
| 219 | /* Disable all LSMs not in the ordered list. */ | ||
| 220 | for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { | ||
| 221 | if (exists_ordered_lsm(lsm)) | ||
| 222 | continue; | ||
| 223 | set_enabled(lsm, false); | ||
| 224 | init_debug("%s disabled: %s\n", origin, lsm->name); | ||
| 225 | } | ||
| 226 | |||
| 211 | kfree(sep); | 227 | kfree(sep); |
| 212 | } | 228 | } |
| 213 | 229 | ||
| @@ -229,22 +245,6 @@ static void __init ordered_lsm_init(void) | |||
| 229 | kfree(ordered_lsms); | 245 | kfree(ordered_lsms); |
| 230 | } | 246 | } |
| 231 | 247 | ||
| 232 | static void __init major_lsm_init(void) | ||
| 233 | { | ||
| 234 | struct lsm_info *lsm; | ||
| 235 | |||
| 236 | for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { | ||
| 237 | if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0) | ||
| 238 | continue; | ||
| 239 | |||
| 240 | /* Enable this LSM, if it is not already set. */ | ||
| 241 | if (!lsm->enabled) | ||
| 242 | lsm->enabled = &lsm_enabled_true; | ||
| 243 | |||
| 244 | maybe_initialize_lsm(lsm); | ||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | /** | 248 | /** |
| 249 | * security_init - initializes the security framework | 249 | * security_init - initializes the security framework |
| 250 | * | 250 | * |
| @@ -271,11 +271,6 @@ int __init security_init(void) | |||
| 271 | /* Load LSMs in specified order. */ | 271 | /* Load LSMs in specified order. */ |
| 272 | ordered_lsm_init(); | 272 | ordered_lsm_init(); |
| 273 | 273 | ||
| 274 | /* | ||
| 275 | * Load all the remaining security modules. | ||
| 276 | */ | ||
| 277 | major_lsm_init(); | ||
| 278 | |||
| 279 | return 0; | 274 | return 0; |
| 280 | } | 275 | } |
| 281 | 276 | ||
