aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/ima/ima.h
diff options
context:
space:
mode:
authorMimi Zohar <zohar@linux.vnet.ibm.com>2012-02-13 10:15:05 -0500
committerMimi Zohar <zohar@linux.vnet.ibm.com>2012-09-07 14:57:44 -0400
commit2fe5d6def1672ae6635dd71867bf36dcfaa7434b (patch)
treef83878d309605440b5bc2d2d43a16ccece64c645 /security/integrity/ima/ima.h
parent4199d35cbc90c15db447d115bd96ffa5f1d60d3a (diff)
ima: integrity appraisal extension
IMA currently maintains an integrity measurement list used to assert the integrity of the running system to a third party. The IMA-appraisal extension adds local integrity validation and enforcement of the measurement against a "good" value stored as an extended attribute 'security.ima'. The initial methods for validating 'security.ima' are hashed based, which provides file data integrity, and digital signature based, which in addition to providing file data integrity, provides authenticity. This patch creates and maintains the 'security.ima' xattr, containing the file data hash measurement. Protection of the xattr is provided by EVM, if enabled and configured. Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata integrity and, assuming success, compares the file's current hash value with the one stored as an extended attribute in 'security.ima'. Changelov v4: - changed iint cache flags to hex values Changelog v3: - change appraisal default for filesystems without xattr support to fail Changelog v2: - fix audit msg 'res' value - removed unused 'ima_appraise=' values Changelog v1: - removed unused iint mutex (Dmitry Kasatkin) - setattr hook must not reset appraised (Dmitry Kasatkin) - evm_verifyxattr() now differentiates between no 'security.evm' xattr (INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the 'security.evm' (INTEGRITY_NOXATTRS). - replace hash_status with ima_status (Dmitry Kasatkin) - re-initialize slab element ima_status on free (Dmitry Kasatkin) - include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA - merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin) - removed unnecessary error variable in process_measurement() (Dmitry Kasatkin) - use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured (moved ima_inode_post_setattr() to ima_appraise.c) - make sure ima_collect_measurement() can read file Changelog: - add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin) - fix the race condition between chmod, which takes the i_mutex and then iint->mutex, and ima_file_free() and process_measurement(), which take the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin) - cleanup of ima_appraise_measurement() (Dmitry Kasatkin) - changes as a result of the iint not allocated for all regular files, but only for those measured/appraised. - don't try to appraise new/empty files - expanded ima_appraisal description in ima/Kconfig - IMA appraise definitions required even if IMA_APPRAISE not enabled - add return value to ima_must_appraise() stub - unconditionally set status = INTEGRITY_PASS *after* testing status, not before. (Found by Joe Perches) Signed-off-by: Mimi Zohar <zohar@us.ibm.com> Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Diffstat (limited to 'security/integrity/ima/ima.h')
-rw-r--r--security/integrity/ima/ima.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index e7c99fd0d223..069a4aa63e95 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -40,6 +40,7 @@ enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8 };
40extern int ima_initialized; 40extern int ima_initialized;
41extern int ima_used_chip; 41extern int ima_used_chip;
42extern char *ima_hash; 42extern char *ima_hash;
43extern int ima_appraise;
43 44
44/* IMA inode template definition */ 45/* IMA inode template definition */
45struct ima_template_data { 46struct ima_template_data {
@@ -107,6 +108,7 @@ static inline unsigned long ima_hash_key(u8 *digest)
107} 108}
108 109
109/* LIM API function definitions */ 110/* LIM API function definitions */
111int ima_must_appraise_or_measure(struct inode *inode, int mask, int function);
110int ima_must_measure(struct inode *inode, int mask, int function); 112int ima_must_measure(struct inode *inode, int mask, int function);
111int ima_collect_measurement(struct integrity_iint_cache *iint, 113int ima_collect_measurement(struct integrity_iint_cache *iint,
112 struct file *file); 114 struct file *file);
@@ -123,14 +125,45 @@ struct integrity_iint_cache *integrity_iint_insert(struct inode *inode);
123struct integrity_iint_cache *integrity_iint_find(struct inode *inode); 125struct integrity_iint_cache *integrity_iint_find(struct inode *inode);
124 126
125/* IMA policy related functions */ 127/* IMA policy related functions */
126enum ima_hooks { FILE_CHECK = 1, FILE_MMAP, BPRM_CHECK }; 128enum ima_hooks { FILE_CHECK = 1, FILE_MMAP, BPRM_CHECK, POST_SETATTR };
127 129
128int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask); 130int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask,
131 int flags);
129void ima_init_policy(void); 132void ima_init_policy(void);
130void ima_update_policy(void); 133void ima_update_policy(void);
131ssize_t ima_parse_add_rule(char *); 134ssize_t ima_parse_add_rule(char *);
132void ima_delete_rules(void); 135void ima_delete_rules(void);
133 136
137/* Appraise integrity measurements */
138#define IMA_APPRAISE_ENFORCE 0x01
139#define IMA_APPRAISE_FIX 0x02
140
141#ifdef CONFIG_IMA_APPRAISE
142int ima_appraise_measurement(struct integrity_iint_cache *iint,
143 struct file *file, const unsigned char *filename);
144int ima_must_appraise(struct inode *inode, enum ima_hooks func, int mask);
145void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file);
146
147#else
148static inline int ima_appraise_measurement(struct integrity_iint_cache *iint,
149 struct file *file,
150 const unsigned char *filename)
151{
152 return INTEGRITY_UNKNOWN;
153}
154
155static inline int ima_must_appraise(struct inode *inode,
156 enum ima_hooks func, int mask)
157{
158 return 0;
159}
160
161static inline void ima_update_xattr(struct integrity_iint_cache *iint,
162 struct file *file)
163{
164}
165#endif
166
134/* LSM based policy rules require audit */ 167/* LSM based policy rules require audit */
135#ifdef CONFIG_IMA_LSM_RULES 168#ifdef CONFIG_IMA_LSM_RULES
136 169