Skip to content

Commit

Permalink
ima: hashing large files bug fix
Browse files Browse the repository at this point in the history
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>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Mimi Zohar authored and James Morris committed Aug 24, 2009
1 parent 6777d77 commit 16bfa38
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/integrity/ima/ima_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down

0 comments on commit 16bfa38

Please sign in to comment.