Commit 2e3a34e9 authored by Roberto Sassu's avatar Roberto Sassu Committed by Mimi Zohar

ima: Fix return value of ima_write_policy()

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: 19f8a847 ("ima: measure and appraise the IMA policy itself")
Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: default avatarKrzysztof Struczynski <krzysztof.struczynski@huawei.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
parent 53de3b08
...@@ -338,7 +338,6 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf, ...@@ -338,7 +338,6 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL, integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL,
"policy_update", "signed policy required", "policy_update", "signed policy required",
1, 0); 1, 0);
if (ima_appraise & IMA_APPRAISE_ENFORCE)
result = -EACCES; result = -EACCES;
} else { } else {
result = ima_parse_add_rule(data); result = ima_parse_add_rule(data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment