aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/ima/ima_api.c
diff options
context:
space:
mode:
authorDmitry Kasatkin <d.kasatkin@samsung.com>2013-04-25 03:44:04 -0400
committerMimi Zohar <zohar@linux.vnet.ibm.com>2013-10-25 17:16:59 -0400
commitd3634d0f426bdeb433cb288bdbb0a5e16cf3dbbf (patch)
tree2197b45ddbdfcc81ecdc6b5acaa9292eead795b7 /security/integrity/ima/ima_api.c
parentc7c8bb237fdbff932b5e431aebee5ce862ea07d1 (diff)
ima: read and use signature hash algorithm
All files on the filesystem, currently, are hashed using the same hash algorithm. In preparation for files from different packages being signed using different hash algorithms, this patch adds support for reading the signature hash algorithm from the 'security.ima' extended attribute and calculates the appropriate file data hash based on it. Changelog: - fix scripts Lindent and checkpatch msgs - Mimi - fix md5 support for older version, which occupied 20 bytes in the xattr, not the expected 16 bytes. Fix the comparison to compare only the first 16 bytes. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security/integrity/ima/ima_api.c')
-rw-r--r--security/integrity/ima/ima_api.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index e531fe22e582..1dba98e2d7e9 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -139,17 +139,27 @@ int ima_must_measure(struct inode *inode, int mask, int function)
139 * Return 0 on success, error code otherwise 139 * Return 0 on success, error code otherwise
140 */ 140 */
141int ima_collect_measurement(struct integrity_iint_cache *iint, 141int ima_collect_measurement(struct integrity_iint_cache *iint,
142 struct file *file) 142 struct file *file,
143 struct evm_ima_xattr_data **xattr_value,
144 int *xattr_len)
143{ 145{
144 struct inode *inode = file_inode(file); 146 struct inode *inode = file_inode(file);
145 const char *filename = file->f_dentry->d_name.name; 147 const char *filename = file->f_dentry->d_name.name;
146 int result = 0; 148 int result = 0;
147 149
150 if (xattr_value)
151 *xattr_len = ima_read_xattr(file->f_dentry, xattr_value);
152
148 if (!(iint->flags & IMA_COLLECTED)) { 153 if (!(iint->flags & IMA_COLLECTED)) {
149 u64 i_version = file_inode(file)->i_version; 154 u64 i_version = file_inode(file)->i_version;
150 155
151 /* use default hash algorithm */ 156 /* use default hash algorithm */
152 iint->ima_hash.algo = ima_hash_algo; 157 iint->ima_hash.algo = ima_hash_algo;
158
159 if (xattr_value)
160 ima_get_hash_algo(*xattr_value, *xattr_len,
161 &iint->ima_hash);
162
153 result = ima_calc_file_hash(file, &iint->ima_hash); 163 result = ima_calc_file_hash(file, &iint->ima_hash);
154 if (!result) { 164 if (!result) {
155 iint->version = i_version; 165 iint->version = i_version;