Skip to content

Commit 0311507

Browse files
bowerscd-corppcmoore
authored andcommitted
lsm: add IPE lsm
Integrity Policy Enforcement (IPE) is an LSM that provides an complimentary approach to Mandatory Access Control than existing LSMs today. Existing LSMs have centered around the concept of access to a resource should be controlled by the current user's credentials. IPE's approach, is that access to a resource should be controlled by the system's trust of a current resource. The basis of this approach is defining a global policy to specify which resource can be trusted. Signed-off-by: Deven Bowers <[email protected]> Signed-off-by: Fan Wu <[email protected]> [PM: subject line tweak] Signed-off-by: Paul Moore <[email protected]>
1 parent 9ee6881 commit 0311507

File tree

9 files changed

+97
-6
lines changed

9 files changed

+97
-6
lines changed

include/uapi/linux/lsm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct lsm_ctx {
6464
#define LSM_ID_LANDLOCK 110
6565
#define LSM_ID_IMA 111
6666
#define LSM_ID_EVM 112
67+
#define LSM_ID_IPE 113
6768

6869
/*
6970
* LSM_ATTR_XXX definitions identify different LSM attributes

security/Kconfig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ source "security/yama/Kconfig"
192192
source "security/safesetid/Kconfig"
193193
source "security/lockdown/Kconfig"
194194
source "security/landlock/Kconfig"
195+
source "security/ipe/Kconfig"
195196

196197
source "security/integrity/Kconfig"
197198

@@ -231,11 +232,11 @@ endchoice
231232

232233
config LSM
233234
string "Ordered list of enabled LSMs"
234-
default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,bpf" if DEFAULT_SECURITY_SMACK
235-
default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,bpf" if DEFAULT_SECURITY_APPARMOR
236-
default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,bpf" if DEFAULT_SECURITY_TOMOYO
237-
default "landlock,lockdown,yama,loadpin,safesetid,bpf" if DEFAULT_SECURITY_DAC
238-
default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,bpf"
235+
default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,ipe,bpf" if DEFAULT_SECURITY_SMACK
236+
default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,ipe,bpf" if DEFAULT_SECURITY_APPARMOR
237+
default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,ipe,bpf" if DEFAULT_SECURITY_TOMOYO
238+
default "landlock,lockdown,yama,loadpin,safesetid,ipe,bpf" if DEFAULT_SECURITY_DAC
239+
default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,ipe,bpf"
239240
help
240241
A comma-separated list of LSMs, in initialization order.
241242
Any LSMs left off this list, except for those with order

security/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ obj-$(CONFIG_SECURITY_LOCKDOWN_LSM) += lockdown/
2525
obj-$(CONFIG_CGROUPS) += device_cgroup.o
2626
obj-$(CONFIG_BPF_LSM) += bpf/
2727
obj-$(CONFIG_SECURITY_LANDLOCK) += landlock/
28+
obj-$(CONFIG_SECURITY_IPE) += ipe/
2829

2930
# Object integrity file lists
3031
obj-$(CONFIG_INTEGRITY) += integrity/

security/ipe/Kconfig

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-only
2+
#
3+
# Integrity Policy Enforcement (IPE) configuration
4+
#
5+
6+
menuconfig SECURITY_IPE
7+
bool "Integrity Policy Enforcement (IPE)"
8+
depends on SECURITY && SECURITYFS
9+
select PKCS7_MESSAGE_PARSER
10+
select SYSTEM_DATA_VERIFICATION
11+
help
12+
This option enables the Integrity Policy Enforcement LSM
13+
allowing users to define a policy to enforce a trust-based access
14+
control. A key feature of IPE is a customizable policy to allow
15+
admins to reconfigure trust requirements on the fly.
16+
17+
If unsure, answer N.

security/ipe/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved.
4+
#
5+
# Makefile for building the IPE module as part of the kernel tree.
6+
#
7+
8+
obj-$(CONFIG_SECURITY_IPE) += \
9+
ipe.o \

security/ipe/ipe.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved.
4+
*/
5+
#include <uapi/linux/lsm.h>
6+
7+
#include "ipe.h"
8+
9+
static struct lsm_blob_sizes ipe_blobs __ro_after_init = {
10+
};
11+
12+
static const struct lsm_id ipe_lsmid = {
13+
.name = "ipe",
14+
.id = LSM_ID_IPE,
15+
};
16+
17+
static struct security_hook_list ipe_hooks[] __ro_after_init = {
18+
};
19+
20+
/**
21+
* ipe_init() - Entry point of IPE.
22+
*
23+
* This is called at LSM init, which happens occurs early during kernel
24+
* start up. During this phase, IPE registers its hooks and loads the
25+
* builtin boot policy.
26+
*
27+
* Return:
28+
* * %0 - OK
29+
* * %-ENOMEM - Out of memory (OOM)
30+
*/
31+
static int __init ipe_init(void)
32+
{
33+
security_add_hooks(ipe_hooks, ARRAY_SIZE(ipe_hooks), &ipe_lsmid);
34+
35+
return 0;
36+
}
37+
38+
DEFINE_LSM(ipe) = {
39+
.name = "ipe",
40+
.init = ipe_init,
41+
.blobs = &ipe_blobs,
42+
};

security/ipe/ipe.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+
* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved.
4+
*/
5+
6+
#ifndef _IPE_H
7+
#define _IPE_H
8+
9+
#ifdef pr_fmt
10+
#undef pr_fmt
11+
#endif
12+
#define pr_fmt(fmt) "ipe: " fmt
13+
14+
#include <linux/lsm_hooks.h>
15+
16+
#endif /* _IPE_H */

security/security.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
(IS_ENABLED(CONFIG_BPF_LSM) ? 1 : 0) + \
5454
(IS_ENABLED(CONFIG_SECURITY_LANDLOCK) ? 1 : 0) + \
5555
(IS_ENABLED(CONFIG_IMA) ? 1 : 0) + \
56-
(IS_ENABLED(CONFIG_EVM) ? 1 : 0))
56+
(IS_ENABLED(CONFIG_EVM) ? 1 : 0) + \
57+
(IS_ENABLED(CONFIG_SECURITY_IPE) ? 1 : 0))
5758

5859
/*
5960
* These are descriptions of the reasons that can be passed to the

tools/testing/selftests/lsm/lsm_list_modules_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ TEST(correct_lsm_list_modules)
128128
case LSM_ID_EVM:
129129
name = "evm";
130130
break;
131+
case LSM_ID_IPE:
132+
name = "ipe";
133+
break;
131134
default:
132135
name = "INVALID";
133136
break;

0 commit comments

Comments
 (0)