mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] kernel_read: redefine offset type
@ 2009-08-21 18:32 Mimi Zohar
  2009-08-21 18:32 ` [PATCH 2/2] ima: hashing large files bug fix Mimi Zohar
  2009-08-24  4:58 ` [PATCH 1/2] kernel_read: redefine offset type James Morris
  0 siblings, 2 replies; 4+ messages in thread
From: Mimi Zohar @ 2009-08-21 18:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Mimi Zohar, Al Viro, James Morris, Roland Kletzing,
	<David Safford, stable, Mimi Zohar

vfs_read() offset is defined as loff_t, but kernel_read()
offset is only defined as unsigned long. Redefine
kernel_read() offset as loff_t.

Cc: stable@kernel.org
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
---
 fs/exec.c          |    4 ++--
 include/linux/fs.h |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 4a8849e..fb4f3cd 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -678,8 +678,8 @@ exit:
 }
 EXPORT_SYMBOL(open_exec);
 
-int kernel_read(struct file *file, unsigned long offset,
-	char *addr, unsigned long count)
+int kernel_read(struct file *file, loff_t offset,
+		char *addr, unsigned long count)
 {
 	mm_segment_t old_fs;
 	loff_t pos = offset;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 67888a9..73e9b64 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2123,7 +2123,7 @@ extern struct file *do_filp_open(int dfd, const char *pathname,
 		int open_flag, int mode, int acc_mode);
 extern int may_open(struct path *, int, int);
 
-extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
+extern int kernel_read(struct file *, loff_t, char *, unsigned long);
 extern struct file * open_exec(const char *);
  
 /* fs/dcache.c -- generic fs support functions */
-- 
1.6.0.6


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

* [PATCH 2/2] ima: hashing large files bug fix
  2009-08-21 18:32 [PATCH 1/2] kernel_read: redefine offset type Mimi Zohar
@ 2009-08-21 18:32 ` Mimi Zohar
  2009-08-24  4:57   ` James Morris
  2009-08-24  4:58 ` [PATCH 1/2] kernel_read: redefine offset type James Morris
  1 sibling, 1 reply; 4+ messages in thread
From: Mimi Zohar @ 2009-08-21 18:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Mimi Zohar, Al Viro, James Morris, Roland Kletzing,
	<David Safford, stable, Mimi Zohar

Hashing files larger than INT_MAX causes process to loop.
Dependent on redefining kernel_read() offset type to loff_t.

(http://bugzilla.kernel.org/show_bug.cgi?id=13909)

Cc: stable@kernel.org
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
---
 security/integrity/ima/ima_crypto.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
index 63003a6..46642a1 100644
--- a/security/integrity/ima/ima_crypto.c
+++ b/security/integrity/ima/ima_crypto.c
@@ -45,9 +45,9 @@ int ima_calc_hash(struct file *file, char *digest)
 {
 	struct hash_desc desc;
 	struct scatterlist sg[1];
-	loff_t i_size;
+	loff_t i_size, offset = 0;
 	char *rbuf;
-	int rc, offset = 0;
+	int rc;
 
 	rc = init_desc(&desc);
 	if (rc != 0)
@@ -67,6 +67,8 @@ int ima_calc_hash(struct file *file, char *digest)
 			rc = rbuf_len;
 			break;
 		}
+		if (rbuf_len == 0)
+			break;
 		offset += rbuf_len;
 		sg_init_one(sg, rbuf, rbuf_len);
 
-- 
1.6.0.6


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

* Re: [PATCH 2/2] ima: hashing large files bug fix
  2009-08-21 18:32 ` [PATCH 2/2] ima: hashing large files bug fix Mimi Zohar
@ 2009-08-24  4:57   ` James Morris
  0 siblings, 0 replies; 4+ messages in thread
From: James Morris @ 2009-08-24  4:57 UTC (permalink / raw)
  To: Mimi Zohar, Linus Torvalds
  Cc: linux-kernel, Al Viro, Roland Kletzing, <David Safford,
	stable, Mimi Zohar

On Fri, 21 Aug 2009, Mimi Zohar wrote:

> Hashing files larger than INT_MAX causes process to loop.
> Dependent on redefining kernel_read() offset type to loff_t.
> 
> (http://bugzilla.kernel.org/show_bug.cgi?id=13909)
> 
> Cc: stable@kernel.org
> Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
> ---
>  security/integrity/ima/ima_crypto.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)

These look correct to me (I'll also push them to Linus via git).

Reviewed-by: James Morris <jmorris@namei.org>

> 
> diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
> index 63003a6..46642a1 100644
> --- a/security/integrity/ima/ima_crypto.c
> +++ b/security/integrity/ima/ima_crypto.c
> @@ -45,9 +45,9 @@ int ima_calc_hash(struct file *file, char *digest)
>  {
>  	struct hash_desc desc;
>  	struct scatterlist sg[1];
> -	loff_t i_size;
> +	loff_t i_size, offset = 0;
>  	char *rbuf;
> -	int rc, offset = 0;
> +	int rc;
>  
>  	rc = init_desc(&desc);
>  	if (rc != 0)
> @@ -67,6 +67,8 @@ int ima_calc_hash(struct file *file, char *digest)
>  			rc = rbuf_len;
>  			break;
>  		}
> +		if (rbuf_len == 0)
> +			break;
>  		offset += rbuf_len;
>  		sg_init_one(sg, rbuf, rbuf_len);
>  
> -- 
> 1.6.0.6
> 

-- 
James Morris
<jmorris@namei.org>

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

* Re: [PATCH 1/2] kernel_read: redefine offset type
  2009-08-21 18:32 [PATCH 1/2] kernel_read: redefine offset type Mimi Zohar
  2009-08-21 18:32 ` [PATCH 2/2] ima: hashing large files bug fix Mimi Zohar
@ 2009-08-24  4:58 ` James Morris
  1 sibling, 0 replies; 4+ messages in thread
From: James Morris @ 2009-08-24  4:58 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: linux-kernel, Al Viro, Roland Kletzing, <David Safford,
	stable, Mimi Zohar

On Fri, 21 Aug 2009, Mimi Zohar wrote:

> vfs_read() offset is defined as loff_t, but kernel_read()
> offset is only defined as unsigned long. Redefine
> kernel_read() offset as loff_t.
> 
> Cc: stable@kernel.org
> Signed-off-by: Mimi Zohar <zohar@us.ibm.com>


Reviewed-by: James Morris <jmorris@namei.org>

> ---
>  fs/exec.c          |    4 ++--
>  include/linux/fs.h |    2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/exec.c b/fs/exec.c
> index 4a8849e..fb4f3cd 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -678,8 +678,8 @@ exit:
>  }
>  EXPORT_SYMBOL(open_exec);
>  
> -int kernel_read(struct file *file, unsigned long offset,
> -	char *addr, unsigned long count)
> +int kernel_read(struct file *file, loff_t offset,
> +		char *addr, unsigned long count)
>  {
>  	mm_segment_t old_fs;
>  	loff_t pos = offset;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 67888a9..73e9b64 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2123,7 +2123,7 @@ extern struct file *do_filp_open(int dfd, const char *pathname,
>  		int open_flag, int mode, int acc_mode);
>  extern int may_open(struct path *, int, int);
>  
> -extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
> +extern int kernel_read(struct file *, loff_t, char *, unsigned long);
>  extern struct file * open_exec(const char *);
>   
>  /* fs/dcache.c -- generic fs support functions */
> -- 
> 1.6.0.6
> 

-- 
James Morris
<jmorris@namei.org>

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

end of thread, other threads:[~2009-08-24  4:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-21 18:32 [PATCH 1/2] kernel_read: redefine offset type Mimi Zohar
2009-08-21 18:32 ` [PATCH 2/2] ima: hashing large files bug fix Mimi Zohar
2009-08-24  4:57   ` James Morris
2009-08-24  4:58 ` [PATCH 1/2] kernel_read: redefine offset type James Morris

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

all inboxes | Powered by JetHome®