aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-09-19 20:30:09 -0400
committerKees Cook <keescook@chromium.org>2019-01-08 16:18:42 -0500
commit79f7865d844c7703e3dc0e2f5b9ed2f3a4f412e5 (patch)
tree0e4804064ab81e886d5b9d0836abe27af5f155ed
parent13e735c0e953246bd531d342bb86acb5b1bf664a (diff)
LSM: Introduce "lsm=" for boottime LSM selection
Provide a way to explicitly choose LSM initialization order via the new "lsm=" comma-separated list of LSMs. Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt4
-rw-r--r--security/Kconfig3
-rw-r--r--security/security.c14
3 files changed, 19 insertions, 2 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b799bcf67d7b..e59e1471d4db 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2319,6 +2319,10 @@
2319 2319
2320 lsm.debug [SECURITY] Enable LSM initialization debugging output. 2320 lsm.debug [SECURITY] Enable LSM initialization debugging output.
2321 2321
2322 lsm=lsm1,...,lsmN
2323 [SECURITY] Choose order of LSM initialization. This
2324 overrides CONFIG_LSM.
2325
2322 machvec= [IA-64] Force the use of a particular machine-vector 2326 machvec= [IA-64] Force the use of a particular machine-vector
2323 (machvec) in a generic kernel. 2327 (machvec) in a generic kernel.
2324 Example: machvec=hpzx1_swiotlb 2328 Example: machvec=hpzx1_swiotlb
diff --git a/security/Kconfig b/security/Kconfig
index 7f21190cb677..cedf69e8a22c 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -281,7 +281,8 @@ config LSM
281 default "integrity" 281 default "integrity"
282 help 282 help
283 A comma-separated list of LSMs, in initialization order. 283 A comma-separated list of LSMs, in initialization order.
284 Any LSMs left off this list will be ignored. 284 Any LSMs left off this list will be ignored. This can be
285 controlled at boot with the "lsm=" parameter.
285 286
286 If unsure, leave this as the default. 287 If unsure, leave this as the default.
287 288
diff --git a/security/security.c b/security/security.c
index 11a42cd313c5..2e1f48e8a6f2 100644
--- a/security/security.c
+++ b/security/security.c
@@ -47,6 +47,7 @@ char *lsm_names;
47/* Boot-time LSM user choice */ 47/* Boot-time LSM user choice */
48static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = 48static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
49 CONFIG_DEFAULT_SECURITY; 49 CONFIG_DEFAULT_SECURITY;
50static __initdata const char *chosen_lsm_order;
50 51
51static __initconst const char * const builtin_lsm_order = CONFIG_LSM; 52static __initconst const char * const builtin_lsm_order = CONFIG_LSM;
52 53
@@ -190,7 +191,10 @@ static void __init ordered_lsm_init(void)
190 ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms), 191 ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms),
191 GFP_KERNEL); 192 GFP_KERNEL);
192 193
193 ordered_lsm_parse(builtin_lsm_order, "builtin"); 194 if (chosen_lsm_order)
195 ordered_lsm_parse(chosen_lsm_order, "cmdline");
196 else
197 ordered_lsm_parse(builtin_lsm_order, "builtin");
194 198
195 for (lsm = ordered_lsms; *lsm; lsm++) 199 for (lsm = ordered_lsms; *lsm; lsm++)
196 maybe_initialize_lsm(*lsm); 200 maybe_initialize_lsm(*lsm);
@@ -252,6 +256,14 @@ static int __init choose_lsm(char *str)
252} 256}
253__setup("security=", choose_lsm); 257__setup("security=", choose_lsm);
254 258
259/* Explicitly choose LSM initialization order. */
260static int __init choose_lsm_order(char *str)
261{
262 chosen_lsm_order = str;
263 return 1;
264}
265__setup("lsm=", choose_lsm_order);
266
255/* Enable LSM order debugging. */ 267/* Enable LSM order debugging. */
256static int __init enable_debug(char *str) 268static int __init enable_debug(char *str)
257{ 269{