diff options
Diffstat (limited to 'security/integrity/ima/ima_appraise.c')
-rw-r--r-- | security/integrity/ima/ima_appraise.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 86bfd5c5df85..7c8f41e618b6 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c | |||
@@ -23,6 +23,8 @@ static int __init default_appraise_setup(char *str) | |||
23 | { | 23 | { |
24 | if (strncmp(str, "off", 3) == 0) | 24 | if (strncmp(str, "off", 3) == 0) |
25 | ima_appraise = 0; | 25 | ima_appraise = 0; |
26 | else if (strncmp(str, "log", 3) == 0) | ||
27 | ima_appraise = IMA_APPRAISE_LOG; | ||
26 | else if (strncmp(str, "fix", 3) == 0) | 28 | else if (strncmp(str, "fix", 3) == 0) |
27 | ima_appraise = IMA_APPRAISE_FIX; | 29 | ima_appraise = IMA_APPRAISE_FIX; |
28 | return 1; | 30 | return 1; |
@@ -183,7 +185,7 @@ int ima_read_xattr(struct dentry *dentry, | |||
183 | int ima_appraise_measurement(int func, struct integrity_iint_cache *iint, | 185 | int ima_appraise_measurement(int func, struct integrity_iint_cache *iint, |
184 | struct file *file, const unsigned char *filename, | 186 | struct file *file, const unsigned char *filename, |
185 | struct evm_ima_xattr_data *xattr_value, | 187 | struct evm_ima_xattr_data *xattr_value, |
186 | int xattr_len) | 188 | int xattr_len, int opened) |
187 | { | 189 | { |
188 | static const char op[] = "appraise_data"; | 190 | static const char op[] = "appraise_data"; |
189 | char *cause = "unknown"; | 191 | char *cause = "unknown"; |
@@ -192,8 +194,6 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint, | |||
192 | enum integrity_status status = INTEGRITY_UNKNOWN; | 194 | enum integrity_status status = INTEGRITY_UNKNOWN; |
193 | int rc = xattr_len, hash_start = 0; | 195 | int rc = xattr_len, hash_start = 0; |
194 | 196 | ||
195 | if (!ima_appraise) | ||
196 | return 0; | ||
197 | if (!inode->i_op->getxattr) | 197 | if (!inode->i_op->getxattr) |
198 | return INTEGRITY_UNKNOWN; | 198 | return INTEGRITY_UNKNOWN; |
199 | 199 | ||
@@ -202,8 +202,11 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint, | |||
202 | goto out; | 202 | goto out; |
203 | 203 | ||
204 | cause = "missing-hash"; | 204 | cause = "missing-hash"; |
205 | status = | 205 | status = INTEGRITY_NOLABEL; |
206 | (inode->i_size == 0) ? INTEGRITY_PASS : INTEGRITY_NOLABEL; | 206 | if (opened & FILE_CREATED) { |
207 | iint->flags |= IMA_NEW_FILE; | ||
208 | status = INTEGRITY_PASS; | ||
209 | } | ||
207 | goto out; | 210 | goto out; |
208 | } | 211 | } |
209 | 212 | ||
@@ -315,7 +318,7 @@ void ima_inode_post_setattr(struct dentry *dentry) | |||
315 | struct integrity_iint_cache *iint; | 318 | struct integrity_iint_cache *iint; |
316 | int must_appraise, rc; | 319 | int must_appraise, rc; |
317 | 320 | ||
318 | if (!ima_initialized || !ima_appraise || !S_ISREG(inode->i_mode) | 321 | if (!(ima_policy_flag & IMA_APPRAISE) || !S_ISREG(inode->i_mode) |
319 | || !inode->i_op->removexattr) | 322 | || !inode->i_op->removexattr) |
320 | return; | 323 | return; |
321 | 324 | ||
@@ -353,7 +356,7 @@ static void ima_reset_appraise_flags(struct inode *inode, int digsig) | |||
353 | { | 356 | { |
354 | struct integrity_iint_cache *iint; | 357 | struct integrity_iint_cache *iint; |
355 | 358 | ||
356 | if (!ima_initialized || !ima_appraise || !S_ISREG(inode->i_mode)) | 359 | if (!(ima_policy_flag & IMA_APPRAISE) || !S_ISREG(inode->i_mode)) |
357 | return; | 360 | return; |
358 | 361 | ||
359 | iint = integrity_iint_find(inode); | 362 | iint = integrity_iint_find(inode); |
@@ -375,6 +378,8 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, | |||
375 | result = ima_protect_xattr(dentry, xattr_name, xattr_value, | 378 | result = ima_protect_xattr(dentry, xattr_name, xattr_value, |
376 | xattr_value_len); | 379 | xattr_value_len); |
377 | if (result == 1) { | 380 | if (result == 1) { |
381 | if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST)) | ||
382 | return -EINVAL; | ||
378 | ima_reset_appraise_flags(dentry->d_inode, | 383 | ima_reset_appraise_flags(dentry->d_inode, |
379 | (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0); | 384 | (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0); |
380 | result = 0; | 385 | result = 0; |