aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Glöckner <dg@emlix.com>2017-02-24 09:05:14 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-25 09:44:34 -0400
commit91034255e42f6026bafb8e8e2b707eb937104bc8 (patch)
treecd99774bb9933a31c15e0d0c1fccd18650bd1731
parentce7146cf9bdf490b9380af2a5d60bc65c68dbcb9 (diff)
ima: accept previously set IMA_NEW_FILE
commit 1ac202e978e18f045006d75bd549612620c6ec3a 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>
-rw-r--r--security/integrity/ima/ima_appraise.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 389325ac6067..097459830454 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -204,10 +204,11 @@ int ima_appraise_measurement(enum ima_hooks func,
204 204
205 cause = "missing-hash"; 205 cause = "missing-hash";
206 status = INTEGRITY_NOLABEL; 206 status = INTEGRITY_NOLABEL;
207 if (opened & FILE_CREATED) { 207 if (opened & FILE_CREATED)
208 iint->flags |= IMA_NEW_FILE; 208 iint->flags |= IMA_NEW_FILE;
209 if ((iint->flags & IMA_NEW_FILE) &&
210 !(iint->flags & IMA_DIGSIG_REQUIRED))
209 status = INTEGRITY_PASS; 211 status = INTEGRITY_PASS;
210 }
211 goto out; 212 goto out;
212 } 213 }
213 214