diff options
author | Dmitry Kasatkin <d.kasatkin@samsung.com> | 2014-03-28 08:31:04 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2014-06-12 17:58:06 -0400 |
commit | d3b33679481d52ef02311119d4342a9a1f3d84db (patch) | |
tree | 5e23d255b52239a4d478dc8b56e49871a4b732c4 /security | |
parent | 060bdebfb0b82751be89c0ce4b6e2c88606a354b (diff) |
evm: replace HMAC version with attribute mask
Using HMAC version limits the posibility to arbitrarily add new
attributes such as SMACK64EXEC to the hmac calculation.
This patch replaces hmac version with attribute mask.
Desired attributes can be enabled with configuration parameter.
It allows to build kernels which works with previously labeled
filesystems.
Currently supported attribute is 'fsuuid' which is equivalent of
the former version 2.
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/evm/Kconfig | 25 | ||||
-rw-r--r-- | security/integrity/evm/evm.h | 5 | ||||
-rw-r--r-- | security/integrity/evm/evm_crypto.c | 2 | ||||
-rw-r--r-- | security/integrity/evm/evm_main.c | 12 |
4 files changed, 33 insertions, 11 deletions
diff --git a/security/integrity/evm/Kconfig b/security/integrity/evm/Kconfig index d35b4915b00d..0df4f7a2f1e9 100644 --- a/security/integrity/evm/Kconfig +++ b/security/integrity/evm/Kconfig | |||
@@ -12,15 +12,24 @@ config EVM | |||
12 | 12 | ||
13 | If you are unsure how to answer this question, answer N. | 13 | If you are unsure how to answer this question, answer N. |
14 | 14 | ||
15 | config EVM_HMAC_VERSION | 15 | if EVM |
16 | int "EVM HMAC version" | 16 | |
17 | menu "EVM options" | ||
18 | |||
19 | config EVM_ATTR_FSUUID | ||
20 | bool "FSUUID (version 2)" | ||
21 | default y | ||
17 | depends on EVM | 22 | depends on EVM |
18 | default 2 | ||
19 | help | 23 | help |
20 | This options adds EVM HMAC version support. | 24 | Include filesystem UUID for HMAC calculation. |
21 | 1 - original version | 25 | |
22 | 2 - add per filesystem unique identifier (UUID) (default) | 26 | Default value is 'selected', which is former version 2. |
27 | if 'not selected', it is former version 1 | ||
23 | 28 | ||
24 | WARNING: changing the HMAC calculation method or adding | 29 | WARNING: changing the HMAC calculation method or adding |
25 | additional info to the calculation, requires existing EVM | 30 | additional info to the calculation, requires existing EVM |
26 | labeled file systems to be relabeled. | 31 | labeled file systems to be relabeled. |
32 | |||
33 | endmenu | ||
34 | |||
35 | endif | ||
diff --git a/security/integrity/evm/evm.h b/security/integrity/evm/evm.h index 37c88ddb3cfe..88bfe77efa1c 100644 --- a/security/integrity/evm/evm.h +++ b/security/integrity/evm/evm.h | |||
@@ -24,7 +24,10 @@ | |||
24 | extern int evm_initialized; | 24 | extern int evm_initialized; |
25 | extern char *evm_hmac; | 25 | extern char *evm_hmac; |
26 | extern char *evm_hash; | 26 | extern char *evm_hash; |
27 | extern int evm_hmac_version; | 27 | |
28 | #define EVM_ATTR_FSUUID 0x0001 | ||
29 | |||
30 | extern int evm_hmac_attrs; | ||
28 | 31 | ||
29 | extern struct crypto_shash *hmac_tfm; | 32 | extern struct crypto_shash *hmac_tfm; |
30 | extern struct crypto_shash *hash_tfm; | 33 | extern struct crypto_shash *hash_tfm; |
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c index 6b540f1822e0..5e9687f02e1b 100644 --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c | |||
@@ -112,7 +112,7 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode, | |||
112 | hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid); | 112 | hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid); |
113 | hmac_misc.mode = inode->i_mode; | 113 | hmac_misc.mode = inode->i_mode; |
114 | crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); | 114 | crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); |
115 | if (evm_hmac_version > 1) | 115 | if (evm_hmac_attrs & EVM_ATTR_FSUUID) |
116 | crypto_shash_update(desc, inode->i_sb->s_uuid, | 116 | crypto_shash_update(desc, inode->i_sb->s_uuid, |
117 | sizeof(inode->i_sb->s_uuid)); | 117 | sizeof(inode->i_sb->s_uuid)); |
118 | crypto_shash_final(desc, digest); | 118 | crypto_shash_final(desc, digest); |
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 6e0bd933b6a9..1dc09190a948 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
@@ -32,7 +32,7 @@ static char *integrity_status_msg[] = { | |||
32 | }; | 32 | }; |
33 | char *evm_hmac = "hmac(sha1)"; | 33 | char *evm_hmac = "hmac(sha1)"; |
34 | char *evm_hash = "sha1"; | 34 | char *evm_hash = "sha1"; |
35 | int evm_hmac_version = CONFIG_EVM_HMAC_VERSION; | 35 | int evm_hmac_attrs; |
36 | 36 | ||
37 | char *evm_config_xattrnames[] = { | 37 | char *evm_config_xattrnames[] = { |
38 | #ifdef CONFIG_SECURITY_SELINUX | 38 | #ifdef CONFIG_SECURITY_SELINUX |
@@ -57,6 +57,14 @@ static int __init evm_set_fixmode(char *str) | |||
57 | } | 57 | } |
58 | __setup("evm=", evm_set_fixmode); | 58 | __setup("evm=", evm_set_fixmode); |
59 | 59 | ||
60 | static void __init evm_init_config(void) | ||
61 | { | ||
62 | #ifdef CONFIG_EVM_ATTR_FSUUID | ||
63 | evm_hmac_attrs |= EVM_ATTR_FSUUID; | ||
64 | #endif | ||
65 | pr_info("HMAC attrs: 0x%x\n", evm_hmac_attrs); | ||
66 | } | ||
67 | |||
60 | static int evm_find_protected_xattrs(struct dentry *dentry) | 68 | static int evm_find_protected_xattrs(struct dentry *dentry) |
61 | { | 69 | { |
62 | struct inode *inode = dentry->d_inode; | 70 | struct inode *inode = dentry->d_inode; |
@@ -432,6 +440,8 @@ static int __init init_evm(void) | |||
432 | { | 440 | { |
433 | int error; | 441 | int error; |
434 | 442 | ||
443 | evm_init_config(); | ||
444 | |||
435 | error = evm_init_secfs(); | 445 | error = evm_init_secfs(); |
436 | if (error < 0) { | 446 | if (error < 0) { |
437 | pr_info("Error registering secfs\n"); | 447 | pr_info("Error registering secfs\n"); |