Skip to content

Commit 9b8c7c1

Browse files
keesJames Morris
authored andcommitted
LSM: Provide init debugging infrastructure
Booting with "lsm.debug" will report future details on how LSM ordering decisions are being made. Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: John Johansen <john.johansen@canonical.com> Reviewed-by: James Morris <james.morris@microsoft.com> Signed-off-by: James Morris <james.morris@microsoft.com>
1 parent 07aed2f commit 9b8c7c1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,8 @@
22742274
ltpc= [NET]
22752275
Format: <io>,<irq>,<dma>
22762276

2277+
lsm.debug [SECURITY] Enable LSM initialization debugging output.
2278+
22772279
machvec= [IA-64] Force the use of a particular machine-vector
22782280
(machvec) in a generic kernel.
22792281
Example: machvec=hpzx1_swiotlb

security/security.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* (at your option) any later version.
1313
*/
1414

15+
#define pr_fmt(fmt) "LSM: " fmt
16+
1517
#include <linux/bpf.h>
1618
#include <linux/capability.h>
1719
#include <linux/dcache.h>
@@ -43,11 +45,19 @@ char *lsm_names;
4345
static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
4446
CONFIG_DEFAULT_SECURITY;
4547

48+
static __initdata bool debug;
49+
#define init_debug(...) \
50+
do { \
51+
if (debug) \
52+
pr_info(__VA_ARGS__); \
53+
} while (0)
54+
4655
static void __init major_lsm_init(void)
4756
{
4857
struct lsm_info *lsm;
4958

5059
for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) {
60+
init_debug("initializing %s\n", lsm->name);
5161
lsm->init();
5262
}
5363
}
@@ -91,6 +101,14 @@ static int __init choose_lsm(char *str)
91101
}
92102
__setup("security=", choose_lsm);
93103

104+
/* Enable LSM order debugging. */
105+
static int __init enable_debug(char *str)
106+
{
107+
debug = true;
108+
return 1;
109+
}
110+
__setup("lsm.debug", enable_debug);
111+
94112
static bool match_last_lsm(const char *list, const char *lsm)
95113
{
96114
const char *last;

0 commit comments

Comments
 (0)