All of lore.kernel.org
 help / color / mirror / Atom feed
From: roberto.sassu@huawei.com (Roberto Sassu)
To: linux-security-module@vger.kernel.org
Subject: [RFC][PATCH v2 2/9] ima: preserve flags in ima_inode_post_setattr() if file must be appraised
Date: Thu, 30 Nov 2017 11:56:03 +0100	[thread overview]
Message-ID: <20171130105610.15761-3-roberto.sassu@huawei.com> (raw)
In-Reply-To: <20171130105610.15761-1-roberto.sassu@huawei.com>

Before commit d79d72e02485 ("ima: per hook cache integrity appraisal
status"), ima_inode_post_setattr() clears the iint flags only if the file
does not match policy rules after attributes changed. After the commit
above, it clears the flags in any case. This patch restores the original
behavior.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 security/integrity/ima/ima_appraise.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 1b56ee949315..a54ad18affb1 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -360,11 +360,13 @@ void ima_inode_post_setattr(struct dentry *dentry)
 	must_appraise = ima_must_appraise(inode, MAY_ACCESS, POST_SETATTR);
 	iint = integrity_iint_find(inode);
 	if (iint) {
-		iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
-				 IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK |
-				 IMA_ACTION_RULE_FLAGS);
 		if (must_appraise)
 			iint->flags |= IMA_APPRAISE;
+		else
+			iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
+					 IMA_APPRAISE_SUBMASK |
+					 IMA_APPRAISED_SUBMASK |
+					 IMA_ACTION_RULE_FLAGS);
 	}
 	if (!must_appraise)
 		__vfs_removexattr(dentry, XATTR_NAME_IMA);
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Roberto Sassu <roberto.sassu@huawei.com>
To: <linux-integrity@vger.kernel.org>
Cc: <linux-security-module@vger.kernel.org>,
	<silviu.vlasceanu@huawei.com>,
	Roberto Sassu <roberto.sassu@huawei.com>
Subject: [RFC][PATCH v2 2/9] ima: preserve flags in ima_inode_post_setattr() if file must be appraised
Date: Thu, 30 Nov 2017 11:56:03 +0100	[thread overview]
Message-ID: <20171130105610.15761-3-roberto.sassu@huawei.com> (raw)
In-Reply-To: <20171130105610.15761-1-roberto.sassu@huawei.com>

Before commit d79d72e02485 ("ima: per hook cache integrity appraisal
status"), ima_inode_post_setattr() clears the iint flags only if the file
does not match policy rules after attributes changed. After the commit
above, it clears the flags in any case. This patch restores the original
behavior.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 security/integrity/ima/ima_appraise.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 1b56ee949315..a54ad18affb1 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -360,11 +360,13 @@ void ima_inode_post_setattr(struct dentry *dentry)
 	must_appraise = ima_must_appraise(inode, MAY_ACCESS, POST_SETATTR);
 	iint = integrity_iint_find(inode);
 	if (iint) {
-		iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
-				 IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK |
-				 IMA_ACTION_RULE_FLAGS);
 		if (must_appraise)
 			iint->flags |= IMA_APPRAISE;
+		else
+			iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
+					 IMA_APPRAISE_SUBMASK |
+					 IMA_APPRAISED_SUBMASK |
+					 IMA_ACTION_RULE_FLAGS);
 	}
 	if (!must_appraise)
 		__vfs_removexattr(dentry, XATTR_NAME_IMA);
-- 
2.11.0

  parent reply	other threads:[~2017-11-30 10:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 10:56 [RFC][PATCH v2 0/9] ima: integrity models for appraised files Roberto Sassu
2017-11-30 10:56 ` Roberto Sassu
2017-11-30 10:56 ` [RFC][PATCH v2 1/9] ima: pass filename to ima_rdwr_violation_check() Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-12-01 17:38   ` Mimi Zohar
2017-12-01 17:38     ` Mimi Zohar
2017-11-30 10:56 ` Roberto Sassu [this message]
2017-11-30 10:56   ` [RFC][PATCH v2 2/9] ima: preserve flags in ima_inode_post_setattr() if file must be appraised Roberto Sassu
2017-12-01 16:31   ` Mimi Zohar
2017-12-01 16:31     ` Mimi Zohar
2017-11-30 10:56 ` [RFC][PATCH v2 3/9] ima: preserve iint flags if security.ima update is successful Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-12-01 18:06   ` Mimi Zohar
2017-12-01 18:06     ` Mimi Zohar
2017-11-30 10:56 ` [RFC][PATCH v2 4/9] ima: introduce ima_mk_null_file() Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-11-30 10:56 ` [RFC][PATCH v2 5/9] ima: measure/appraise/audit inherited file descriptors Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-11-30 10:56 ` [RFC][PATCH v2 6/9] ima: enforce the Biba strict policy on appraised files Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-11-30 10:56 ` [RFC][PATCH v2 7/9] ima: enforce the Biba low watermark for objects " Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-11-30 10:56 ` [RFC][PATCH v2 8/9] ima: introduce policy action try_appraise Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu
2017-11-30 10:56 ` [RFC][PATCH v2 9/9] ima: don't measure files with valid appraisal status Roberto Sassu
2017-11-30 10:56   ` Roberto Sassu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171130105610.15761-3-roberto.sassu@huawei.com \
    --to=roberto.sassu@huawei.com \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.