Message ID | 1350380076-15997-1-git-send-email-lczerner@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, 16 Oct 2012, Lukas Czerner wrote: > Date: Tue, 16 Oct 2012 11:34:36 +0200 > From: Lukas Czerner <lczerner@redhat.com> > To: linux-btrfs@vger.kernel.org > Cc: jbacik@fusionio.com, Lukas Czerner <lczerner@redhat.com> > Subject: [PATCH] btrfs: Return EINVAL when length to trim is less than FSB > > Currently if len argument in btrfs_ioctl_fitrim() is smaller than > one FSB we will continue and finally return 0 bytes discarded. > However if the length to discard is smaller then file system block > we should really return EINVAL. ping > > Signed-off-by: Lukas Czerner <lczerner@redhat.com> > --- > fs/btrfs/ioctl.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 6116880..3b8b509 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -343,7 +343,8 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg) > return -EOPNOTSUPP; > if (copy_from_user(&range, arg, sizeof(range))) > return -EFAULT; > - if (range.start > total_bytes) > + if (range.start > total_bytes || > + range.len < fs_info->sb->s_blocksize) > return -EINVAL; > > range.len = min(range.len, total_bytes - range.start); > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2012/10/24 16:15, Lukáš Czerner wrote: > On Tue, 16 Oct 2012, Lukas Czerner wrote: > >> Date: Tue, 16 Oct 2012 11:34:36 +0200 >> From: Lukas Czerner <lczerner@redhat.com> >> To: linux-btrfs@vger.kernel.org >> Cc: jbacik@fusionio.com, Lukas Czerner <lczerner@redhat.com> >> Subject: [PATCH] btrfs: Return EINVAL when length to trim is less than FSB >> >> Currently if len argument in btrfs_ioctl_fitrim() is smaller than >> one FSB we will continue and finally return 0 bytes discarded. >> However if the length to discard is smaller then file system block >> we should really return EINVAL. > > ping > This patch has already sit in Josef's btrfs-next tree: http://git.kernel.org/?p=linux/kernel/git/josef/btrfs-next.git;a=commit;h=cd50b6b30f09446eafdd715db6d59299fcc5b19a -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 6116880..3b8b509 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -343,7 +343,8 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg) return -EOPNOTSUPP; if (copy_from_user(&range, arg, sizeof(range))) return -EFAULT; - if (range.start > total_bytes) + if (range.start > total_bytes || + range.len < fs_info->sb->s_blocksize) return -EINVAL; range.len = min(range.len, total_bytes - range.start);
Currently if len argument in btrfs_ioctl_fitrim() is smaller than one FSB we will continue and finally return 0 bytes discarded. However if the length to discard is smaller then file system block we should really return EINVAL. Signed-off-by: Lukas Czerner <lczerner@redhat.com> --- fs/btrfs/ioctl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)