Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223065
b: refs/heads/master
c: 7572777
h: refs/heads/master
i:
  223063: 43676b7
v: v3
  • Loading branch information
Miklos Szeredi committed Nov 30, 2010
1 parent 3088ba6 commit 902adc7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d9d318d39dd5cb686660504a3565aac453709ccc
refs/heads/master: 7572777eef78ebdee1ecb7c258c0ef94d35bad16
22 changes: 22 additions & 0 deletions trunk/fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,20 @@ static int fuse_copy_ioctl_iovec(struct iovec *dst, void *src,
return 0;
}

/* Make sure iov_length() won't overflow */
static int fuse_verify_ioctl_iov(struct iovec *iov, size_t count)
{
size_t n;
u32 max = FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT;

for (n = 0; n < count; n++) {
if (iov->iov_len > (size_t) max)
return -ENOMEM;
max -= iov->iov_len;
}
return 0;
}

/*
* For ioctls, there is no generic way to determine how much memory
* needs to be read and/or written. Furthermore, ioctls are allowed
Expand Down Expand Up @@ -1858,6 +1872,14 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
in_iov = page_address(iov_page);
out_iov = in_iov + in_iovs;

err = fuse_verify_ioctl_iov(in_iov, in_iovs);
if (err)
goto out;

err = fuse_verify_ioctl_iov(out_iov, out_iovs);
if (err)
goto out;

goto retry;
}

Expand Down

0 comments on commit 902adc7

Please sign in to comment.