Skip to content

Commit 250898c

Browse files
committed
lsm: rework lsm_active_cnt and lsm_idlist[]
Move the LSM active count and lsm_id list declarations out of a header that is visible across the kernel and into a header that is limited to the LSM framework. This not only helps keep the include/linux headers smaller and cleaner, it helps prevent misuse of these variables. Reviewed-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: John Johansen <john.johhansen@canonical.com> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 592b104 commit 250898c

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

include/linux/security.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ struct lsm_prop {
167167
};
168168

169169
extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
170-
extern u32 lsm_active_cnt;
171-
extern const struct lsm_id *lsm_idlist[];
172170

173171
/* These functions are in security/commoncap.c */
174172
extern int cap_capable(const struct cred *cred, struct user_namespace *ns,

security/lsm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
#define _LSM_H_
88

99
#include <linux/lsm_hooks.h>
10+
#include <linux/lsm_count.h>
11+
12+
/* List of configured LSMs */
13+
extern unsigned int lsm_active_cnt;
14+
extern const struct lsm_id *lsm_idlist[];
1015

1116
/* LSM blob configuration */
1217
extern struct lsm_blob_sizes blob_sizes;

security/lsm_init.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,6 @@ static void __init initialize_lsm(struct lsm_info *lsm)
217217
}
218218
}
219219

220-
/*
221-
* Current index to use while initializing the lsm id list.
222-
*/
223-
u32 lsm_active_cnt __ro_after_init;
224-
const struct lsm_id *lsm_idlist[MAX_LSM_COUNT];
225-
226220
/* Populate ordered LSMs list from comma-separated LSM name list. */
227221
static void __init ordered_lsm_parse(const char *order, const char *origin)
228222
{

security/lsm_syscalls.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/lsm_hooks.h>
1818
#include <uapi/linux/lsm.h>
1919

20+
#include "lsm.h"
21+
2022
/**
2123
* lsm_name_to_attr - map an LSM attribute name to its ID
2224
* @name: name of the attribute

security/security.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX + 1] = {
7373
[LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
7474
};
7575

76+
unsigned int lsm_active_cnt __ro_after_init;
77+
const struct lsm_id *lsm_idlist[MAX_LSM_COUNT];
78+
7679
struct lsm_blob_sizes blob_sizes;
7780

7881
struct kmem_cache *lsm_file_cache;

0 commit comments

Comments
 (0)