Skip to content

Commit 08e589a

Browse files
dgloeckgregkh
authored andcommitted
ima: accept previously set IMA_NEW_FILE
commit 1ac202e upstream. Modifying the attributes of a file makes ima_inode_post_setattr reset the IMA cache flags. So if the file, which has just been created, is opened a second time before the first file descriptor is closed, verification fails since the security.ima xattr has not been written yet. We therefore have to look at the IMA_NEW_FILE even if the file already existed. With this patch there should no longer be an error when cat tries to open testfile: $ rm -f testfile $ ( echo test >&3 ; touch testfile ; cat testfile ) 3>testfile A file being new is no reason to accept that it is missing a digital signature demanded by the policy. Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0c99c8a commit 08e589a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

security/integrity/ima/ima_appraise.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint,
203203

204204
cause = "missing-hash";
205205
status = INTEGRITY_NOLABEL;
206-
if (opened & FILE_CREATED) {
206+
if (opened & FILE_CREATED)
207207
iint->flags |= IMA_NEW_FILE;
208+
if ((iint->flags & IMA_NEW_FILE) &&
209+
!(iint->flags & IMA_DIGSIG_REQUIRED))
208210
status = INTEGRITY_PASS;
209-
}
210211
goto out;
211212
}
212213

0 commit comments

Comments
 (0)