Skip to content

Commit f4dc377

Browse files
Dmitry KasatkinMimi Zohar
authored andcommitted
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>
1 parent ebd68df commit f4dc377

File tree

7 files changed

+35
-22
lines changed

7 files changed

+35
-22
lines changed

security/integrity/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ config INTEGRITY_ASYMMETRIC_KEYS
4141
This option enables digital signature verification using
4242
asymmetric keys.
4343

44+
config 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+
4455
config INTEGRITY_AUDIT
4556
bool "Enables integrity auditing support "
4657
depends on AUDIT

security/integrity/digsig.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,22 @@
2424
static struct key *keyring[INTEGRITY_KEYRING_MAX];
2525

2626
static const char *keyring_name[INTEGRITY_KEYRING_MAX] = {
27+
#ifndef CONFIG_INTEGRITY_TRUSTED_KEYRING
2728
"_evm",
28-
"_module",
29-
#ifndef CONFIG_IMA_TRUSTED_KEYRING
3029
"_ima",
3130
#else
31+
".evm",
3232
".ima",
3333
#endif
34+
"_module",
3435
};
3536

37+
#ifdef CONFIG_INTEGRITY_TRUSTED_KEYRING
38+
static bool init_keyring __initdata = true;
39+
#else
40+
static bool init_keyring __initdata;
41+
#endif
42+
3643
int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
3744
const char *digest, int digestlen)
3845
{
@@ -68,6 +75,9 @@ int __init integrity_init_keyring(const unsigned int id)
6875
const struct cred *cred = current_cred();
6976
int err = 0;
7077

78+
if (!init_keyring)
79+
return 0;
80+
7181
keyring[id] = keyring_alloc(keyring_name[id], KUIDT_INIT(0),
7282
KGIDT_INIT(0), cred,
7383
((KEY_POS_ALL & ~KEY_POS_SETATTR) |

security/integrity/evm/evm_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,17 @@ static int __init init_evm(void)
478478

479479
evm_init_config();
480480

481+
error = integrity_init_keyring(INTEGRITY_KEYRING_EVM);
482+
if (error)
483+
return error;
484+
481485
error = evm_init_secfs();
482486
if (error < 0) {
483487
pr_info("Error registering secfs\n");
484-
goto err;
488+
return error;
485489
}
486490

487491
return 0;
488-
err:
489-
return error;
490492
}
491493

492494
/*

security/integrity/ima/Kconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,17 @@ config IMA_APPRAISE
123123
If unsure, say N.
124124

125125
config 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)"
127127
depends on IMA_APPRAISE && SYSTEM_TRUSTED_KEYRING
128128
depends on INTEGRITY_ASYMMETRIC_KEYS
129+
select INTEGRITY_TRUSTED_KEYRING
129130
default y
130131
help
131132
This option requires that all keys added to the .ima
132133
keyring be signed by a key on the system trusted keyring.
133134

135+
This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING
136+
134137
config IMA_LOAD_X509
135138
bool "Load X509 certificate onto the '.ima' trusted keyring"
136139
depends on IMA_TRUSTED_KEYRING

security/integrity/ima/ima.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,4 @@ static inline int security_filter_rule_match(u32 secid, u32 field, u32 op,
251251
return -EINVAL;
252252
}
253253
#endif /* CONFIG_IMA_LSM_RULES */
254-
255-
#ifdef CONFIG_IMA_TRUSTED_KEYRING
256-
static inline int ima_init_keyring(const unsigned int id)
257-
{
258-
return integrity_init_keyring(id);
259-
}
260-
#else
261-
static inline int ima_init_keyring(const unsigned int id)
262-
{
263-
return 0;
264-
}
265-
#endif /* CONFIG_IMA_TRUSTED_KEYRING */
266254
#endif

security/integrity/ima/ima_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int __init ima_init(void)
116116
if (!ima_used_chip)
117117
pr_info("No TPM chip found, activating TPM-bypass!\n");
118118

119-
rc = ima_init_keyring(INTEGRITY_KEYRING_IMA);
119+
rc = integrity_init_keyring(INTEGRITY_KEYRING_IMA);
120120
if (rc)
121121
return rc;
122122

security/integrity/integrity.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ int integrity_kernel_read(struct file *file, loff_t offset,
125125
int __init integrity_read_file(const char *path, char **data);
126126

127127
#define INTEGRITY_KEYRING_EVM 0
128-
#define INTEGRITY_KEYRING_MODULE 1
129-
#define INTEGRITY_KEYRING_IMA 2
128+
#define INTEGRITY_KEYRING_IMA 1
129+
#define INTEGRITY_KEYRING_MODULE 2
130130
#define INTEGRITY_KEYRING_MAX 3
131131

132132
#ifdef CONFIG_INTEGRITY_SIGNATURE
@@ -149,7 +149,6 @@ static inline int integrity_init_keyring(const unsigned int id)
149149
{
150150
return 0;
151151
}
152-
153152
#endif /* CONFIG_INTEGRITY_SIGNATURE */
154153

155154
#ifdef CONFIG_INTEGRITY_ASYMMETRIC_KEYS

0 commit comments

Comments
 (0)