aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity
diff options
context:
space:
mode:
authorJames Morris <james.l.morris@oracle.com>2016-05-05 19:29:00 -0400
committerJames Morris <james.l.morris@oracle.com>2016-05-05 19:29:00 -0400
commit0250abcd726b4eba8a6175f09656fe544ed6491a (patch)
tree43ded3d5f9b8b5684879c61ff6d03effdb7ea7c0 /security/integrity
parent74f430cd0fdee1bdfb25708ee1e52fc860535a89 (diff)
parentd55201ce08bfae40ae0062be126f49471a55bcad (diff)
Merge tag 'keys-next-20160505' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into next
Diffstat (limited to 'security/integrity')
-rw-r--r--security/integrity/Kconfig1
-rw-r--r--security/integrity/digsig.c15
-rw-r--r--security/integrity/ima/Kconfig36
-rw-r--r--security/integrity/ima/Makefile2
-rw-r--r--security/integrity/ima/ima_mok.c23
5 files changed, 42 insertions, 35 deletions
diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig
index 979be65d22c4..da9565891738 100644
--- a/security/integrity/Kconfig
+++ b/security/integrity/Kconfig
@@ -35,7 +35,6 @@ config INTEGRITY_ASYMMETRIC_KEYS
35 default n 35 default n
36 select ASYMMETRIC_KEY_TYPE 36 select ASYMMETRIC_KEY_TYPE
37 select ASYMMETRIC_PUBLIC_KEY_SUBTYPE 37 select ASYMMETRIC_PUBLIC_KEY_SUBTYPE
38 select PUBLIC_KEY_ALGO_RSA
39 select CRYPTO_RSA 38 select CRYPTO_RSA
40 select X509_CERTIFICATE_PARSER 39 select X509_CERTIFICATE_PARSER
41 help 40 help
diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
index 8ef15118cc78..4304372b323f 100644
--- a/security/integrity/digsig.c
+++ b/security/integrity/digsig.c
@@ -18,6 +18,8 @@
18#include <linux/cred.h> 18#include <linux/cred.h>
19#include <linux/key-type.h> 19#include <linux/key-type.h>
20#include <linux/digsig.h> 20#include <linux/digsig.h>
21#include <crypto/public_key.h>
22#include <keys/system_keyring.h>
21 23
22#include "integrity.h" 24#include "integrity.h"
23 25
@@ -40,6 +42,12 @@ static bool init_keyring __initdata = true;
40static bool init_keyring __initdata; 42static bool init_keyring __initdata;
41#endif 43#endif
42 44
45#ifdef CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
46#define restrict_link_to_ima restrict_link_by_builtin_and_secondary_trusted
47#else
48#define restrict_link_to_ima restrict_link_by_builtin_trusted
49#endif
50
43int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, 51int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
44 const char *digest, int digestlen) 52 const char *digest, int digestlen)
45{ 53{
@@ -83,10 +91,9 @@ int __init integrity_init_keyring(const unsigned int id)
83 ((KEY_POS_ALL & ~KEY_POS_SETATTR) | 91 ((KEY_POS_ALL & ~KEY_POS_SETATTR) |
84 KEY_USR_VIEW | KEY_USR_READ | 92 KEY_USR_VIEW | KEY_USR_READ |
85 KEY_USR_WRITE | KEY_USR_SEARCH), 93 KEY_USR_WRITE | KEY_USR_SEARCH),
86 KEY_ALLOC_NOT_IN_QUOTA, NULL); 94 KEY_ALLOC_NOT_IN_QUOTA,
87 if (!IS_ERR(keyring[id])) 95 restrict_link_to_ima, NULL);
88 set_bit(KEY_FLAG_TRUSTED_ONLY, &keyring[id]->flags); 96 if (IS_ERR(keyring[id])) {
89 else {
90 err = PTR_ERR(keyring[id]); 97 err = PTR_ERR(keyring[id]);
91 pr_info("Can't allocate %s keyring (%d)\n", 98 pr_info("Can't allocate %s keyring (%d)\n",
92 keyring_name[id], err); 99 keyring_name[id], err);
diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig
index e54a8a8dae94..5487827fa86c 100644
--- a/security/integrity/ima/Kconfig
+++ b/security/integrity/ima/Kconfig
@@ -155,23 +155,33 @@ config IMA_TRUSTED_KEYRING
155 155
156 This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING 156 This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING
157 157
158config IMA_MOK_KEYRING 158config IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
159 bool "Create IMA machine owner keys (MOK) and blacklist keyrings" 159 bool "Permit keys validly signed by a built-in or secondary CA cert (EXPERIMENTAL)"
160 depends on SYSTEM_TRUSTED_KEYRING
161 depends on SECONDARY_TRUSTED_KEYRING
162 depends on INTEGRITY_ASYMMETRIC_KEYS
163 select INTEGRITY_TRUSTED_KEYRING
164 default n
165 help
166 Keys may be added to the IMA or IMA blacklist keyrings, if the
167 key is validly signed by a CA cert in the system built-in or
168 secondary trusted keyrings.
169
170 Intermediate keys between those the kernel has compiled in and the
171 IMA keys to be added may be added to the system secondary keyring,
172 provided they are validly signed by a key already resident in the
173 built-in or secondary trusted keyrings.
174
175config IMA_BLACKLIST_KEYRING
176 bool "Create IMA machine owner blacklist keyrings (EXPERIMENTAL)"
160 depends on SYSTEM_TRUSTED_KEYRING 177 depends on SYSTEM_TRUSTED_KEYRING
161 depends on IMA_TRUSTED_KEYRING 178 depends on IMA_TRUSTED_KEYRING
162 default n 179 default n
163 help 180 help
164 This option creates IMA MOK and blacklist keyrings. IMA MOK is an 181 This option creates an IMA blacklist keyring, which contains all
165 intermediate keyring that sits between .system and .ima keyrings, 182 revoked IMA keys. It is consulted before any other keyring. If
166 effectively forming a simple CA hierarchy. To successfully import a 183 the search is successful the requested operation is rejected and
167 key into .ima_mok it must be signed by a key which CA is in .system 184 an error is returned to the caller.
168 keyring. On turn any key that needs to go in .ima keyring must be
169 signed by CA in either .system or .ima_mok keyrings. IMA MOK is empty
170 at kernel boot.
171
172 IMA blacklist keyring contains all revoked IMA keys. It is consulted
173 before any other keyring. If the search is successful the requested
174 operation is rejected and error is returned to the caller.
175 185
176config IMA_LOAD_X509 186config IMA_LOAD_X509
177 bool "Load X509 certificate onto the '.ima' trusted keyring" 187 bool "Load X509 certificate onto the '.ima' trusted keyring"
diff --git a/security/integrity/ima/Makefile b/security/integrity/ima/Makefile
index a8539f9e060f..9aeaedad1e2b 100644
--- a/security/integrity/ima/Makefile
+++ b/security/integrity/ima/Makefile
@@ -8,4 +8,4 @@ obj-$(CONFIG_IMA) += ima.o
8ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ 8ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \
9 ima_policy.o ima_template.o ima_template_lib.o 9 ima_policy.o ima_template.o ima_template_lib.o
10ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o 10ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o
11obj-$(CONFIG_IMA_MOK_KEYRING) += ima_mok.o 11obj-$(CONFIG_IMA_BLACKLIST_KEYRING) += ima_mok.o
diff --git a/security/integrity/ima/ima_mok.c b/security/integrity/ima/ima_mok.c
index 676885e4320e..74a279957464 100644
--- a/security/integrity/ima/ima_mok.c
+++ b/security/integrity/ima/ima_mok.c
@@ -17,38 +17,29 @@
17#include <linux/cred.h> 17#include <linux/cred.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <keys/asymmetric-type.h> 20#include <keys/system_keyring.h>
21 21
22 22
23struct key *ima_mok_keyring;
24struct key *ima_blacklist_keyring; 23struct key *ima_blacklist_keyring;
25 24
26/* 25/*
27 * Allocate the IMA MOK and blacklist keyrings 26 * Allocate the IMA blacklist keyring
28 */ 27 */
29__init int ima_mok_init(void) 28__init int ima_mok_init(void)
30{ 29{
31 pr_notice("Allocating IMA MOK and blacklist keyrings.\n"); 30 pr_notice("Allocating IMA blacklist keyring.\n");
32
33 ima_mok_keyring = keyring_alloc(".ima_mok",
34 KUIDT_INIT(0), KGIDT_INIT(0), current_cred(),
35 (KEY_POS_ALL & ~KEY_POS_SETATTR) |
36 KEY_USR_VIEW | KEY_USR_READ |
37 KEY_USR_WRITE | KEY_USR_SEARCH,
38 KEY_ALLOC_NOT_IN_QUOTA, NULL);
39 31
40 ima_blacklist_keyring = keyring_alloc(".ima_blacklist", 32 ima_blacklist_keyring = keyring_alloc(".ima_blacklist",
41 KUIDT_INIT(0), KGIDT_INIT(0), current_cred(), 33 KUIDT_INIT(0), KGIDT_INIT(0), current_cred(),
42 (KEY_POS_ALL & ~KEY_POS_SETATTR) | 34 (KEY_POS_ALL & ~KEY_POS_SETATTR) |
43 KEY_USR_VIEW | KEY_USR_READ | 35 KEY_USR_VIEW | KEY_USR_READ |
44 KEY_USR_WRITE | KEY_USR_SEARCH, 36 KEY_USR_WRITE | KEY_USR_SEARCH,
45 KEY_ALLOC_NOT_IN_QUOTA, NULL); 37 KEY_ALLOC_NOT_IN_QUOTA,
38 restrict_link_by_builtin_trusted, NULL);
46 39
47 if (IS_ERR(ima_mok_keyring) || IS_ERR(ima_blacklist_keyring)) 40 if (IS_ERR(ima_blacklist_keyring))
48 panic("Can't allocate IMA MOK or blacklist keyrings."); 41 panic("Can't allocate IMA blacklist keyring.");
49 set_bit(KEY_FLAG_TRUSTED_ONLY, &ima_mok_keyring->flags);
50 42
51 set_bit(KEY_FLAG_TRUSTED_ONLY, &ima_blacklist_keyring->flags);
52 set_bit(KEY_FLAG_KEEP, &ima_blacklist_keyring->flags); 43 set_bit(KEY_FLAG_KEEP, &ima_blacklist_keyring->flags);
53 return 0; 44 return 0;
54} 45}