Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
ima: accept previously set IMA_NEW_FILE
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dgloeck authored and gregkh committed May 25, 2017
1 parent d581128 commit efa8cd1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions security/integrity/ima/ima_appraise.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ int ima_appraise_measurement(enum ima_hooks func,

cause = "missing-hash";
status = INTEGRITY_NOLABEL;
if (opened & FILE_CREATED) {
if (opened & FILE_CREATED)
iint->flags |= IMA_NEW_FILE;
if ((iint->flags & IMA_NEW_FILE) &&
!(iint->flags & IMA_DIGSIG_REQUIRED))
status = INTEGRITY_PASS;
}
goto out;
}

Expand Down

0 comments on commit efa8cd1

Please sign in to comment.