diff options
author | Dmitry Kasatkin <dmitry.kasatkin@nokia.com> | 2011-03-09 14:28:20 -0500 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2011-07-18 12:29:41 -0400 |
commit | 6be5cc5246f807fd8ede9f5f1bb2826f2c598658 (patch) | |
tree | 00fc342eb91fb50df4e8eddfe2a7294b27df8117 /security/integrity | |
parent | 66dbc325afcef909043c30e90930a36823fc734c (diff) |
evm: add support for different security.evm data types
EVM protects a file's security extended attributes(xattrs) against integrity
attacks. The current patchset maintains an HMAC-sha1 value across the security
xattrs, storing the value as the extended attribute 'security.evm'. We
anticipate other methods for protecting the security extended attributes.
This patch reserves the first byte of 'security.evm' as a place holder for
the type of method.
Changelog v6:
- move evm_ima_xattr_type definition to security/integrity/integrity.h
- defined a structure for the EVM xattr called evm_ima_xattr_data
(based on Serge Hallyn's suggestion)
- removed unnecessary memset
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@nokia.com>
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Diffstat (limited to 'security/integrity')
-rw-r--r-- | security/integrity/evm/evm_crypto.c | 11 | ||||
-rw-r--r-- | security/integrity/evm/evm_main.c | 10 | ||||
-rw-r--r-- | security/integrity/integrity.h | 11 |
3 files changed, 23 insertions, 9 deletions
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c index d49bb002f3da..c631b99bda95 100644 --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c | |||
@@ -141,14 +141,17 @@ int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name, | |||
141 | const char *xattr_value, size_t xattr_value_len) | 141 | const char *xattr_value, size_t xattr_value_len) |
142 | { | 142 | { |
143 | struct inode *inode = dentry->d_inode; | 143 | struct inode *inode = dentry->d_inode; |
144 | u8 hmac[SHA1_DIGEST_SIZE]; | 144 | struct evm_ima_xattr_data xattr_data; |
145 | int rc = 0; | 145 | int rc = 0; |
146 | 146 | ||
147 | rc = evm_calc_hmac(dentry, xattr_name, xattr_value, | 147 | rc = evm_calc_hmac(dentry, xattr_name, xattr_value, |
148 | xattr_value_len, hmac); | 148 | xattr_value_len, xattr_data.digest); |
149 | if (rc == 0) | 149 | if (rc == 0) { |
150 | xattr_data.type = EVM_XATTR_HMAC; | ||
150 | rc = __vfs_setxattr_noperm(dentry, XATTR_NAME_EVM, | 151 | rc = __vfs_setxattr_noperm(dentry, XATTR_NAME_EVM, |
151 | hmac, SHA1_DIGEST_SIZE, 0); | 152 | &xattr_data, |
153 | sizeof(xattr_data), 0); | ||
154 | } | ||
152 | else if (rc == -ENODATA) | 155 | else if (rc == -ENODATA) |
153 | rc = inode->i_op->removexattr(dentry, XATTR_NAME_EVM); | 156 | rc = inode->i_op->removexattr(dentry, XATTR_NAME_EVM); |
154 | return rc; | 157 | return rc; |
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index a8fa45fef8f1..c0580dd15ec0 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
@@ -51,20 +51,20 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry, | |||
51 | size_t xattr_value_len, | 51 | size_t xattr_value_len, |
52 | struct integrity_iint_cache *iint) | 52 | struct integrity_iint_cache *iint) |
53 | { | 53 | { |
54 | char hmac_val[SHA1_DIGEST_SIZE]; | 54 | struct evm_ima_xattr_data xattr_data; |
55 | int rc; | 55 | int rc; |
56 | 56 | ||
57 | if (iint->hmac_status != INTEGRITY_UNKNOWN) | 57 | if (iint->hmac_status != INTEGRITY_UNKNOWN) |
58 | return iint->hmac_status; | 58 | return iint->hmac_status; |
59 | 59 | ||
60 | memset(hmac_val, 0, sizeof hmac_val); | ||
61 | rc = evm_calc_hmac(dentry, xattr_name, xattr_value, | 60 | rc = evm_calc_hmac(dentry, xattr_name, xattr_value, |
62 | xattr_value_len, hmac_val); | 61 | xattr_value_len, xattr_data.digest); |
63 | if (rc < 0) | 62 | if (rc < 0) |
64 | return INTEGRITY_UNKNOWN; | 63 | return INTEGRITY_UNKNOWN; |
65 | 64 | ||
66 | rc = vfs_xattr_cmp(dentry, XATTR_NAME_EVM, hmac_val, sizeof hmac_val, | 65 | xattr_data.type = EVM_XATTR_HMAC; |
67 | GFP_NOFS); | 66 | rc = vfs_xattr_cmp(dentry, XATTR_NAME_EVM, (u8 *)&xattr_data, |
67 | sizeof xattr_data, GFP_NOFS); | ||
68 | if (rc < 0) | 68 | if (rc < 0) |
69 | goto err_out; | 69 | goto err_out; |
70 | iint->hmac_status = INTEGRITY_PASS; | 70 | iint->hmac_status = INTEGRITY_PASS; |
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 397a46b3992f..7efbf560b7d5 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h | |||
@@ -18,6 +18,17 @@ | |||
18 | /* iint cache flags */ | 18 | /* iint cache flags */ |
19 | #define IMA_MEASURED 0x01 | 19 | #define IMA_MEASURED 0x01 |
20 | 20 | ||
21 | enum evm_ima_xattr_type { | ||
22 | IMA_XATTR_DIGEST = 0x01, | ||
23 | EVM_XATTR_HMAC, | ||
24 | EVM_IMA_XATTR_DIGSIG, | ||
25 | }; | ||
26 | |||
27 | struct evm_ima_xattr_data { | ||
28 | u8 type; | ||
29 | u8 digest[SHA1_DIGEST_SIZE]; | ||
30 | } __attribute__((packed)); | ||
31 | |||
21 | /* integrity data associated with an inode */ | 32 | /* integrity data associated with an inode */ |
22 | struct integrity_iint_cache { | 33 | struct integrity_iint_cache { |
23 | struct rb_node rb_node; /* rooted in integrity_iint_tree */ | 34 | struct rb_node rb_node; /* rooted in integrity_iint_tree */ |