diff options
-rw-r--r-- | include/linux/integrity.h | 1 | ||||
-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 |
4 files changed, 24 insertions, 9 deletions
diff --git a/include/linux/integrity.h b/include/linux/integrity.h index e715a2abcea2..968443385678 100644 --- a/include/linux/integrity.h +++ b/include/linux/integrity.h | |||
@@ -19,6 +19,7 @@ enum integrity_status { | |||
19 | INTEGRITY_UNKNOWN, | 19 | INTEGRITY_UNKNOWN, |
20 | }; | 20 | }; |
21 | 21 | ||
22 | /* List of EVM protected security xattrs */ | ||
22 | #ifdef CONFIG_INTEGRITY | 23 | #ifdef CONFIG_INTEGRITY |
23 | extern int integrity_inode_alloc(struct inode *inode); | 24 | extern int integrity_inode_alloc(struct inode *inode); |
24 | extern void integrity_inode_free(struct inode *inode); | 25 | extern void integrity_inode_free(struct inode *inode); |
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 */ |