diff mbox series

[v2,6/6] ima: Fix return value of ima_write_policy()

Message ID 20200427103128.19229-1-roberto.sassu@huawei.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/6] ima: Set file->f_mode instead of file->f_flags in ima_calc_file_hash() | expand

Commit Message

Roberto Sassu April 27, 2020, 10:31 a.m. UTC
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.

Changelog

v1:
- deny the operation in all cases (suggested by Mimi, Krzysztof)

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>
---
 security/integrity/ima/ima_fs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Mimi Zohar April 28, 2020, 5:46 p.m. UTC | #1
Hi Roberto,

On Mon, 2020-04-27 at 12:31 +0200, Roberto Sassu wrote:
> 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.
> 
> Changelog
> 
> v1:
> - deny the operation in all cases (suggested by Mimi, Krzysztof)

Relatively recently, people have moved away from including the
"Changelog" in the upstream commit. (I'm removing them now.)  

> 
> 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>

Without the Changelog, the only way of acknowledging people's
contributions is by including their tags.  Krzysztof, did you want to
add your "Reviewed-by" tag?

> ---

People have started putting the Changelog or any comments immediately
below the separator "---" here.

thanks,

Mimi

>  security/integrity/ima/ima_fs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
> index 8b030a1c5e0d..e3fcad871861 100644
> --- a/security/integrity/ima/ima_fs.c
> +++ b/security/integrity/ima/ima_fs.c
> @@ -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);
>  	}
Krzysztof Struczynski April 29, 2020, 6:43 a.m. UTC | #2
Hi Mimi,

> -----Original Message-----
> From: Mimi Zohar [mailto:zohar@linux.ibm.com]
> Sent: Tuesday, April 28, 2020 7:47 PM
> To: Roberto Sassu <roberto.sassu@huawei.com>; Krzysztof Struczynski
> <krzysztof.struczynski@huawei.com>
> Cc: linux-integrity@vger.kernel.org; linux-security-module@vger.kernel.org;
> linux-kernel@vger.kernel.org; Silviu Vlasceanu
> <Silviu.Vlasceanu@huawei.com>; Krzysztof Struczynski
> <krzysztof.struczynski@huawei.com>; stable@vger.kernel.org
> Subject: Re: [PATCH v2 6/6] ima: Fix return value of ima_write_policy()
> 
> Hi Roberto,
> 
> On Mon, 2020-04-27 at 12:31 +0200, Roberto Sassu wrote:
> > 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.
> >
> > Changelog
> >
> > v1:
> > - deny the operation in all cases (suggested by Mimi, Krzysztof)
> 
> Relatively recently, people have moved away from including the "Changelog"
> in the upstream commit. (I'm removing them now.)
> 
> >
> > 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>
> 
> Without the Changelog, the only way of acknowledging people's contributions
> is by including their tags.  Krzysztof, did you want to add your "Reviewed-by"
> tag?

Please add:
Reviewed-by: Krzysztof Struczynski <krzysztof.struczynski@huawei.com>

Thanks,
Krzysztof

> 
> > ---
> 
> People have started putting the Changelog or any comments immediately
> below the separator "---" here.
> 
> thanks,
> 
> Mimi
> 
> >  security/integrity/ima/ima_fs.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/security/integrity/ima/ima_fs.c
> > b/security/integrity/ima/ima_fs.c index 8b030a1c5e0d..e3fcad871861
> > 100644
> > --- a/security/integrity/ima/ima_fs.c
> > +++ b/security/integrity/ima/ima_fs.c
> > @@ -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);
> >  	}
diff mbox series

Patch

diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index 8b030a1c5e0d..e3fcad871861 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -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);
 	}