summaryrefslogtreecommitdiffstats
path: root/security/integrity
diff options
context:
space:
mode:
authorDmitry Kasatkin <dmitry.kasatkin@huawei.com>2015-10-22 14:26:10 -0400
committerMimi Zohar <zohar@linux.vnet.ibm.com>2015-11-23 14:30:02 -0500
commitf4dc37785e9b3373d0cb93125d5579fed2af3a43 (patch)
treeb1bed1b8038d92770cc9881a1ad57b97e1b57dc3 /security/integrity
parentebd68df3f24b318d391d15c458d6f43f340ba36a (diff)
integrity: define '.evm' as a builtin 'trusted' keyring
Require all keys added to the EVM keyring be signed by an existing trusted key on the system trusted keyring. This patch also switches IMA to use integrity_init_keyring(). Changes in v3: * Added 'init_keyring' config based variable to skip initializing keyring instead of using __integrity_init_keyring() wrapper. * Added dependency back to CONFIG_IMA_TRUSTED_KEYRING Changes in v2: * Replace CONFIG_EVM_TRUSTED_KEYRING with IMA and EVM common CONFIG_INTEGRITY_TRUSTED_KEYRING configuration option * Deprecate CONFIG_IMA_TRUSTED_KEYRING but keep it for config file compatibility. (Mimi Zohar) Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security/integrity')
-rw-r--r--security/integrity/Kconfig11
-rw-r--r--security/integrity/digsig.c14
-rw-r--r--security/integrity/evm/evm_main.c8
-rw-r--r--security/integrity/ima/Kconfig5
-rw-r--r--security/integrity/ima/ima.h12
-rw-r--r--security/integrity/ima/ima_init.c2
-rw-r--r--security/integrity/integrity.h5
7 files changed, 35 insertions, 22 deletions
diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig
index 73c457bf5a4a..21d756832b75 100644
--- a/security/integrity/Kconfig
+++ b/security/integrity/Kconfig
@@ -41,6 +41,17 @@ config INTEGRITY_ASYMMETRIC_KEYS
41 This option enables digital signature verification using 41 This option enables digital signature verification using
42 asymmetric keys. 42 asymmetric keys.
43 43
44config INTEGRITY_TRUSTED_KEYRING
45 bool "Require all keys on the integrity keyrings be signed"
46 depends on SYSTEM_TRUSTED_KEYRING
47 depends on INTEGRITY_ASYMMETRIC_KEYS
48 select KEYS_DEBUG_PROC_KEYS
49 default y
50 help
51 This option requires that all keys added to the .ima and
52 .evm keyrings be signed by a key on the system trusted
53 keyring.
54
44config INTEGRITY_AUDIT 55config INTEGRITY_AUDIT
45 bool "Enables integrity auditing support " 56 bool "Enables integrity auditing support "
46 depends on AUDIT 57 depends on AUDIT
diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
index 5be9ffbe90ba..8ef15118cc78 100644
--- a/security/integrity/digsig.c
+++ b/security/integrity/digsig.c
@@ -24,15 +24,22 @@
24static struct key *keyring[INTEGRITY_KEYRING_MAX]; 24static struct key *keyring[INTEGRITY_KEYRING_MAX];
25 25
26static const char *keyring_name[INTEGRITY_KEYRING_MAX] = { 26static const char *keyring_name[INTEGRITY_KEYRING_MAX] = {
27#ifndef CONFIG_INTEGRITY_TRUSTED_KEYRING
27 "_evm", 28 "_evm",
28 "_module",
29#ifndef CONFIG_IMA_TRUSTED_KEYRING
30 "_ima", 29 "_ima",
31#else 30#else
31 ".evm",
32 ".ima", 32 ".ima",
33#endif 33#endif
34 "_module",
34}; 35};
35 36
37#ifdef CONFIG_INTEGRITY_TRUSTED_KEYRING
38static bool init_keyring __initdata = true;
39#else
40static bool init_keyring __initdata;
41#endif
42
36int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, 43int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
37 const char *digest, int digestlen) 44 const char *digest, int digestlen)
38{ 45{
@@ -68,6 +75,9 @@ int __init integrity_init_keyring(const unsigned int id)
68 const struct cred *cred = current_cred(); 75 const struct cred *cred = current_cred();
69 int err = 0; 76 int err = 0;
70 77
78 if (!init_keyring)
79 return 0;
80
71 keyring[id] = keyring_alloc(keyring_name[id], KUIDT_INIT(0), 81 keyring[id] = keyring_alloc(keyring_name[id], KUIDT_INIT(0),
72 KGIDT_INIT(0), cred, 82 KGIDT_INIT(0), cred,
73 ((KEY_POS_ALL & ~KEY_POS_SETATTR) | 83 ((KEY_POS_ALL & ~KEY_POS_SETATTR) |
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 1334e02ae8f4..75b7e3031d2a 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -478,15 +478,17 @@ static int __init init_evm(void)
478 478
479 evm_init_config(); 479 evm_init_config();
480 480
481 error = integrity_init_keyring(INTEGRITY_KEYRING_EVM);
482 if (error)
483 return error;
484
481 error = evm_init_secfs(); 485 error = evm_init_secfs();
482 if (error < 0) { 486 if (error < 0) {
483 pr_info("Error registering secfs\n"); 487 pr_info("Error registering secfs\n");
484 goto err; 488 return error;
485 } 489 }
486 490
487 return 0; 491 return 0;
488err:
489 return error;
490} 492}
491 493
492/* 494/*
diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig
index df303346029b..a292b881c16f 100644
--- a/security/integrity/ima/Kconfig
+++ b/security/integrity/ima/Kconfig
@@ -123,14 +123,17 @@ config IMA_APPRAISE
123 If unsure, say N. 123 If unsure, say N.
124 124
125config IMA_TRUSTED_KEYRING 125config IMA_TRUSTED_KEYRING
126 bool "Require all keys on the .ima keyring be signed" 126 bool "Require all keys on the .ima keyring be signed (deprecated)"
127 depends on IMA_APPRAISE && SYSTEM_TRUSTED_KEYRING 127 depends on IMA_APPRAISE && SYSTEM_TRUSTED_KEYRING
128 depends on INTEGRITY_ASYMMETRIC_KEYS 128 depends on INTEGRITY_ASYMMETRIC_KEYS
129 select INTEGRITY_TRUSTED_KEYRING
129 default y 130 default y
130 help 131 help
131 This option requires that all keys added to the .ima 132 This option requires that all keys added to the .ima
132 keyring be signed by a key on the system trusted keyring. 133 keyring be signed by a key on the system trusted keyring.
133 134
135 This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING
136
134config IMA_LOAD_X509 137config IMA_LOAD_X509
135 bool "Load X509 certificate onto the '.ima' trusted keyring" 138 bool "Load X509 certificate onto the '.ima' trusted keyring"
136 depends on IMA_TRUSTED_KEYRING 139 depends on IMA_TRUSTED_KEYRING
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index e2a60c30df44..9e82367f5190 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -251,16 +251,4 @@ static inline int security_filter_rule_match(u32 secid, u32 field, u32 op,
251 return -EINVAL; 251 return -EINVAL;
252} 252}
253#endif /* CONFIG_IMA_LSM_RULES */ 253#endif /* CONFIG_IMA_LSM_RULES */
254
255#ifdef CONFIG_IMA_TRUSTED_KEYRING
256static inline int ima_init_keyring(const unsigned int id)
257{
258 return integrity_init_keyring(id);
259}
260#else
261static inline int ima_init_keyring(const unsigned int id)
262{
263 return 0;
264}
265#endif /* CONFIG_IMA_TRUSTED_KEYRING */
266#endif 254#endif
diff --git a/security/integrity/ima/ima_init.c b/security/integrity/ima/ima_init.c
index e600cadd231c..bd79f254d204 100644
--- a/security/integrity/ima/ima_init.c
+++ b/security/integrity/ima/ima_init.c
@@ -116,7 +116,7 @@ int __init ima_init(void)
116 if (!ima_used_chip) 116 if (!ima_used_chip)
117 pr_info("No TPM chip found, activating TPM-bypass!\n"); 117 pr_info("No TPM chip found, activating TPM-bypass!\n");
118 118
119 rc = ima_init_keyring(INTEGRITY_KEYRING_IMA); 119 rc = integrity_init_keyring(INTEGRITY_KEYRING_IMA);
120 if (rc) 120 if (rc)
121 return rc; 121 return rc;
122 122
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index 9c6168709d3b..07726a731727 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -125,8 +125,8 @@ int integrity_kernel_read(struct file *file, loff_t offset,
125int __init integrity_read_file(const char *path, char **data); 125int __init integrity_read_file(const char *path, char **data);
126 126
127#define INTEGRITY_KEYRING_EVM 0 127#define INTEGRITY_KEYRING_EVM 0
128#define INTEGRITY_KEYRING_MODULE 1 128#define INTEGRITY_KEYRING_IMA 1
129#define INTEGRITY_KEYRING_IMA 2 129#define INTEGRITY_KEYRING_MODULE 2
130#define INTEGRITY_KEYRING_MAX 3 130#define INTEGRITY_KEYRING_MAX 3
131 131
132#ifdef CONFIG_INTEGRITY_SIGNATURE 132#ifdef CONFIG_INTEGRITY_SIGNATURE
@@ -149,7 +149,6 @@ static inline int integrity_init_keyring(const unsigned int id)
149{ 149{
150 return 0; 150 return 0;
151} 151}
152
153#endif /* CONFIG_INTEGRITY_SIGNATURE */ 152#endif /* CONFIG_INTEGRITY_SIGNATURE */
154 153
155#ifdef CONFIG_INTEGRITY_ASYMMETRIC_KEYS 154#ifdef CONFIG_INTEGRITY_ASYMMETRIC_KEYS