public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] security: ima_file_mmap() don't just return zero
@ 2010-03-06 11:21 Dan Carpenter
  2010-03-06 21:30 ` Vikram Dhillon
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2010-03-06 11:21 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: James Morris, Eric Paris, Al Viro, J.R. Okajima,
	linux-security-module, linux-kernel, kernel-janitors

It seems like we should return an error here.  That's what the comment
says we should do.

I also removed an out of date comment.  It wasn't needed and seemed likely
to get out of date again.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
This was found with a static checker and I have only compile tested it.
The callers all seem to use the return code, but please review carefully.
The code has been like this since the module was merged.

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 294b005..90d5314 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -260,18 +260,17 @@ out:
  * policy decision.
  *
  * Return 0 on success, an error code on failure.
- * (Based on the results of appraise_measurement().)
  */
 int ima_file_mmap(struct file *file, unsigned long prot)
 {
-	int rc;
+	int rc = 0;
 
 	if (!file)
 		return 0;
 	if (prot & PROT_EXEC)
 		rc = process_measurement(file, file->f_dentry->d_name.name,
 					 MAY_EXEC, FILE_MMAP);
-	return 0;
+	return rc;
 }
 
 /**

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] security: ima_file_mmap() don't just return zero
  2010-03-06 11:21 [patch] security: ima_file_mmap() don't just return zero Dan Carpenter
@ 2010-03-06 21:30 ` Vikram Dhillon
       [not found]   ` <OFC651A6C0.BD37C0C8-ON852576DF.0004365B-852576DF.00045289@us.ibm.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Vikram Dhillon @ 2010-03-06 21:30 UTC (permalink / raw)
  To: Dan Carpenter, Mimi Zohar, James Morris, Eric Paris, Al Viro,
	J.R. Okajima, linux-security-module, linux-kernel,
	kernel-janitors

On Sat, Mar 6, 2010 at 6:21 AM, Dan Carpenter <error27@gmail.com> wrote:
> It seems like we should return an error here.  That's what the comment
> says we should do.
>
> I also removed an out of date comment.  It wasn't needed and seemed likely
> to get out of date again.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> This was found with a static checker and I have only compile tested it.
> The callers all seem to use the return code, but please review carefully.
> The code has been like this since the module was merged.
>
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 294b005..90d5314 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -260,18 +260,17 @@ out:
>  * policy decision.
>  *
>  * Return 0 on success, an error code on failure.
> - * (Based on the results of appraise_measurement().)
>  */
>  int ima_file_mmap(struct file *file, unsigned long prot)
>  {
> -       int rc;
> +       int rc = 0;
>
>        if (!file)
>                return 0;
>        if (prot & PROT_EXEC)
>                rc = process_measurement(file, file->f_dentry->d_name.name,
>                                         MAY_EXEC, FILE_MMAP);
> -       return 0;
> +       return rc;
>  }
>
>  /**
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Looks good, and nice work here :)

Acked-by: Vikram Dhillon <dhillonv10@gmail.com>

-- 
Regards,
Vikram Dhillon

~~~
There are lots of Linux users who don't care how the kernel works, but
only want to use it. That is a tribute to how good Linux is.
-- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] security: ima_file_mmap() don't just return zero
       [not found]   ` <OFC651A6C0.BD37C0C8-ON852576DF.0004365B-852576DF.00045289@us.ibm.com>
@ 2010-03-07  3:29     ` Vikram Dhillon
  0 siblings, 0 replies; 3+ messages in thread
From: Vikram Dhillon @ 2010-03-07  3:29 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Eric Paris, Dan Carpenter, J.R. Okajima, James Morris,
	kernel-janitors, linux-kernel, linux-security-module, Al Viro

On Sat, Mar 6, 2010 at 7:47 PM, Mimi Zohar <zohar@us.ibm.com> wrote:
> Vikram Dhillon <dhillonv10@gmail.com> wrote on 03/06/2010 04:30:33 PM:
>
>> On Sat, Mar 6, 2010 at 6:21 AM, Dan Carpenter <error27@gmail.com> wrote:
>> > It seems like we should return an error here.  That's what the comment
>> > says we should do.
>> >
>> > I also removed an out of date comment.  It wasn't needed and seemed
>> > likely
>> > to get out of date again.
>> >
>> > Signed-off-by: Dan Carpenter <error27@gmail.com>
>> > ---
>
> The current code and comment are correct, as the return code will reflect
> the file's integrity appraisal, which hasn't yet been implemented.
>
> Mimi

Oh right :) I guess we aren't at a point yet to enforce integrity, so
what should the return code return? Based on the comment the code
seemed okay but I think we may have to base it on measurement
appraisal in LIM (then again, not too sure if this is the right
approach).

-- 
Regards,
Vikram Dhillon

~~~
There are lots of Linux users who don't care how the kernel works, but
only want to use it. That is a tribute to how good Linux is.
-- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-07  3:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-06 11:21 [patch] security: ima_file_mmap() don't just return zero Dan Carpenter
2010-03-06 21:30 ` Vikram Dhillon
     [not found]   ` <OFC651A6C0.BD37C0C8-ON852576DF.0004365B-852576DF.00045289@us.ibm.com>
2010-03-07  3:29     ` Vikram Dhillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox