All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fuse: verify all ioctl retry iov elements
@ 2012-07-24 19:10 Zach Brown
  2012-08-06 16:21 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Zach Brown @ 2012-07-24 19:10 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: fuse-devel, linux-kernel

Commit 7572777eef78ebdee1ecb7c258c0ef94d35bad16 attempted to verify that
the total iovec from the client doesn't overflow iov_length() but it
only checked the first element.  The iovec could still overflow by
starting with a small element.  The obvious fix is to check all the
elements.

The overflow case doesn't look dangerous to the kernel as the copy is
limited by the length after the overflow.  This fix restores the
intention of returning an error instead of successfully copying less
than the iovec represented.

I found this by code inspection.  I built it but don't have a test case.
I'm cc:ing stable because the initial commit did as well.

Signed-off-by: Zach Brown <zab@redhat.com>
CC: <stable@kernel.org>         [2.6.37+]
---
 fs/fuse/file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b321a68..514f12a 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1700,7 +1700,7 @@ 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++) {
+	for (n = 0; n < count; n++, iov++) {
 		if (iov->iov_len > (size_t) max)
 			return -ENOMEM;
 		max -= iov->iov_len;
-- 
1.7.6.5


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

* Re: [PATCH] fuse: verify all ioctl retry iov elements
  2012-07-24 19:10 [PATCH] fuse: verify all ioctl retry iov elements Zach Brown
@ 2012-08-06 16:21 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2012-08-06 16:21 UTC (permalink / raw)
  To: Zach Brown; +Cc: fuse-devel, linux-kernel

Zach Brown <zab@redhat.com> writes:

> Commit 7572777eef78ebdee1ecb7c258c0ef94d35bad16 attempted to verify that
> the total iovec from the client doesn't overflow iov_length() but it
> only checked the first element.  The iovec could still overflow by
> starting with a small element.  The obvious fix is to check all the
> elements.
>
> The overflow case doesn't look dangerous to the kernel as the copy is
> limited by the length after the overflow.  This fix restores the
> intention of returning an error instead of successfully copying less
> than the iovec represented.
>
> I found this by code inspection.  I built it but don't have a test case.
> I'm cc:ing stable because the initial commit did as well.

Thanks!  Applied.

Miklos


>
> Signed-off-by: Zach Brown <zab@redhat.com>
> CC: <stable@kernel.org>         [2.6.37+]
> ---
>  fs/fuse/file.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index b321a68..514f12a 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1700,7 +1700,7 @@ 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++) {
> +	for (n = 0; n < count; n++, iov++) {
>  		if (iov->iov_len > (size_t) max)
>  			return -ENOMEM;
>  		max -= iov->iov_len;

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

end of thread, other threads:[~2012-08-06 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-24 19:10 [PATCH] fuse: verify all ioctl retry iov elements Zach Brown
2012-08-06 16:21 ` Miklos Szeredi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.