| @@ -396,6 +396,33 @@ int ima_file_check(struct file *file, int mask) · 395 unmodified lines |
| 396 | 396 | } |
| 397 | 397 | EXPORT_SYMBOL_GPL(ima_file_check); |
| 398 | 398 | |
| 399 | +/** |
| 400 | + * ima_post_create_tmpfile - mark newly created tmpfile as new |
| 401 | + * @file : newly created tmpfile |
| 402 | + * |
| 403 | + * No measuring, appraising or auditing of newly created tmpfiles is needed. |
| 404 | + * Skip calling process_measurement(), but indicate which newly, created |
| 405 | + * tmpfiles are in policy. |
| 406 | + */ |
| 407 | +void ima_post_create_tmpfile(struct inode *inode) |
| 408 | +{ |
| 409 | + struct integrity_iint_cache *iint; |
| 410 | + int must_appraise; |
| 411 | + |
| 412 | + must_appraise = ima_must_appraise(inode, MAY_ACCESS, FILE_CHECK); |
| 413 | + if (!must_appraise) |
| 414 | + return; |
| 415 | + |
| 416 | + /* Nothing to do if we can't allocate memory */ |
| 417 | + iint = integrity_inode_get(inode); |
| 418 | + if (!iint) |
| 419 | + return; |
| 420 | + |
| 421 | + /* needed for writing the security xattrs */ |
| 422 | + set_bit(IMA_UPDATE_XATTR, &iint->atomic_flags); |
| 423 | + iint->ima_file_status = INTEGRITY_PASS; |
| 424 | +} |
| 425 | + |
| 399 | 426 | /** |
| 400 | 427 | * ima_post_path_mknod - mark as a new inode |
| 401 | 428 | * @dentry: newly created dentry |
| @@ -413,9 +440,13 @@ void ima_post_path_mknod(struct dentry *dentry) · 11 unmodified lines |
| 413 | 440 | if (!must_appraise) |
| 414 | 441 | return; |
| 415 | 442 | |
| 443 | + /* Nothing to do if we can't allocate memory */ |
| 416 | 444 | iint = integrity_inode_get(inode); |
| 417 | | − if (iint) |
| 418 | | − iint->flags |= IMA_NEW_FILE; |
| 445 | + if (!iint) |
| 446 | + return; |
| 447 | + |
| 448 | + /* needed for re-opening empty files */ |
| 449 | + iint->flags |= IMA_NEW_FILE; |
| 419 | 450 | } |
| 420 | 451 | |
| 421 | 452 | /** |