Skip to content

Commit ed870e3

Browse files
cschauflerpcmoore
authored andcommitted
lsm: add the lsm_prop data structure
When more than one security module is exporting data to audit and networking sub-systems a single 32 bit integer is no longer sufficient to represent the data. Add a structure to be used instead. The lsm_prop structure definition is intended to keep the LSM specific information private to the individual security modules. The module specific information is included in a new set of header files under include/lsm. Each security module is allowed to define the information included for its use in the lsm_prop. SELinux includes a u32 secid. Smack includes a pointer into its global label list. The conditional compilation based on feature inclusion is contained in the include/lsm files. Cc: apparmor@lists.ubuntu.com Cc: bpf@vger.kernel.org Cc: selinux@vger.kernel.org Cc: linux-security-module@vger.kernel.org Suggested-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Acked-by: John Johansen <john.johansen@canonical.com> [PM: added include/linux/lsm/ to MAINTAINERS, subj tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 9852d85 commit ed870e3

File tree

6 files changed

+87
-0
lines changed

6 files changed

+87
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20846,6 +20846,7 @@ Q: https://patchwork.kernel.org/project/linux-security-module/list
2084620846
B: mailto:linux-security-module@vger.kernel.org
2084720847
P: https://github.com/LinuxSecurityModule/kernel/blob/main/README.md
2084820848
T: git https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm.git
20849+
F: include/linux/lsm/
2084920850
F: include/linux/lsm_audit.h
2085020851
F: include/linux/lsm_hook_defs.h
2085120852
F: include/linux/lsm_hooks.h

include/linux/lsm/apparmor.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Linux Security Module interface to other subsystems.
4+
* AppArmor presents single pointer to an aa_label structure.
5+
*/
6+
#ifndef __LINUX_LSM_APPARMOR_H
7+
#define __LINUX_LSM_APPARMOR_H
8+
9+
struct aa_label;
10+
11+
struct lsm_prop_apparmor {
12+
#ifdef CONFIG_SECURITY_APPARMOR
13+
struct aa_label *label;
14+
#endif
15+
};
16+
17+
#endif /* ! __LINUX_LSM_APPARMOR_H */

include/linux/lsm/bpf.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Linux Security Module interface to other subsystems.
4+
* BPF may present a single u32 value.
5+
*/
6+
#ifndef __LINUX_LSM_BPF_H
7+
#define __LINUX_LSM_BPF_H
8+
#include <linux/types.h>
9+
10+
struct lsm_prop_bpf {
11+
#ifdef CONFIG_BPF_LSM
12+
u32 secid;
13+
#endif
14+
};
15+
16+
#endif /* ! __LINUX_LSM_BPF_H */

include/linux/lsm/selinux.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Linux Security Module interface to other subsystems.
4+
* SELinux presents a single u32 value which is known as a secid.
5+
*/
6+
#ifndef __LINUX_LSM_SELINUX_H
7+
#define __LINUX_LSM_SELINUX_H
8+
#include <linux/types.h>
9+
10+
struct lsm_prop_selinux {
11+
#ifdef CONFIG_SECURITY_SELINUX
12+
u32 secid;
13+
#endif
14+
};
15+
16+
#endif /* ! __LINUX_LSM_SELINUX_H */

include/linux/lsm/smack.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Linux Security Module interface to other subsystems.
4+
* Smack presents a pointer into the global Smack label list.
5+
*/
6+
#ifndef __LINUX_LSM_SMACK_H
7+
#define __LINUX_LSM_SMACK_H
8+
9+
struct smack_known;
10+
11+
struct lsm_prop_smack {
12+
#ifdef CONFIG_SECURITY_SMACK
13+
struct smack_known *skp;
14+
#endif
15+
};
16+
17+
#endif /* ! __LINUX_LSM_SMACK_H */

include/linux/security.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include <linux/sockptr.h>
3535
#include <linux/bpf.h>
3636
#include <uapi/linux/lsm.h>
37+
#include <linux/lsm/selinux.h>
38+
#include <linux/lsm/smack.h>
39+
#include <linux/lsm/apparmor.h>
40+
#include <linux/lsm/bpf.h>
3741

3842
struct linux_binprm;
3943
struct cred;
@@ -152,6 +156,22 @@ enum lockdown_reason {
152156
LOCKDOWN_CONFIDENTIALITY_MAX,
153157
};
154158

159+
/* scaffolding */
160+
struct lsm_prop_scaffold {
161+
u32 secid;
162+
};
163+
164+
/*
165+
* Data exported by the security modules
166+
*/
167+
struct lsm_prop {
168+
struct lsm_prop_selinux selinux;
169+
struct lsm_prop_smack smack;
170+
struct lsm_prop_apparmor apparmor;
171+
struct lsm_prop_bpf bpf;
172+
struct lsm_prop_scaffold scaffold;
173+
};
174+
155175
extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
156176
extern u32 lsm_active_cnt;
157177
extern const struct lsm_id *lsm_idlist[];

0 commit comments

Comments
 (0)