ima: Fix return value of ima_write_policy()
authorRoberto Sassu <roberto.sassu@huawei.com>
Mon, 27 Apr 2020 10:31:28 +0000 (12:31 +0200)
committerMimi Zohar <zohar@linux.ibm.com>
Fri, 8 May 2020 01:36:31 +0000 (21:36 -0400)
This patch fixes the return value of ima_write_policy() when a new policy
is directly passed to IMA and the current policy requires appraisal of the
file containing the policy. Currently, if appraisal is not in ENFORCE mode,
ima_write_policy() returns 0 and leads user space applications to an
endless loop. Fix this issue by denying the operation regardless of the
appraisal mode.

Cc: stable@vger.kernel.org # 4.10.x
Fixes: 19f8a84713edc ("ima: measure and appraise the IMA policy itself")
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Krzysztof Struczynski <krzysztof.struczynski@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
security/integrity/ima/ima_fs.c

index a71e822a6e92d4d8feeb3957cbc48f1f1fe82660..3efc8308ad266c3199c69bd2ee1f6f43c4677e78 100644 (file)
@@ -338,8 +338,7 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
                integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL,
                                    "policy_update", "signed policy required",
                                    1, 0);
-               if (ima_appraise & IMA_APPRAISE_ENFORCE)
-                       result = -EACCES;
+               result = -EACCES;
        } else {
                result = ima_parse_add_rule(data);
        }