Skip to content

Commit 79f7865

Browse files
committed
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 <[email protected]>
1 parent 13e735c commit 79f7865

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,10 @@
23192319

23202320
lsm.debug [SECURITY] Enable LSM initialization debugging output.
23212321

2322+
lsm=lsm1,...,lsmN
2323+
[SECURITY] Choose order of LSM initialization. This
2324+
overrides CONFIG_LSM.
2325+
23222326
machvec= [IA-64] Force the use of a particular machine-vector
23232327
(machvec) in a generic kernel.
23242328
Example: machvec=hpzx1_swiotlb

security/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ config LSM
281281
default "integrity"
282282
help
283283
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.
285286

286287
If unsure, leave this as the default.
287288

security/security.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ char *lsm_names;
4747
/* Boot-time LSM user choice */
4848
static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
4949
CONFIG_DEFAULT_SECURITY;
50+
static __initdata const char *chosen_lsm_order;
5051

5152
static __initconst const char * const builtin_lsm_order = CONFIG_LSM;
5253

@@ -190,7 +191,10 @@ static void __init ordered_lsm_init(void)
190191
ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms),
191192
GFP_KERNEL);
192193

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");
194198

195199
for (lsm = ordered_lsms; *lsm; lsm++)
196200
maybe_initialize_lsm(*lsm);
@@ -252,6 +256,14 @@ static int __init choose_lsm(char *str)
252256
}
253257
__setup("security=", choose_lsm);
254258

259+
/* Explicitly choose LSM initialization order. */
260+
static int __init choose_lsm_order(char *str)
261+
{
262+
chosen_lsm_order = str;
263+
return 1;
264+
}
265+
__setup("lsm=", choose_lsm_order);
266+
255267
/* Enable LSM order debugging. */
256268
static int __init enable_debug(char *str)
257269
{

0 commit comments

Comments
 (0)