btrfs: Return EINVAL when length to trim is less than FSB
PATCH 1/1 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.
--- fs/btrfs/ioctl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
fs/btrfs/ioctl.c +2 -1
@@ -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);
Signature · 1 line
1.7.7.6
Quoted 10 lines · Lukas Czerner
Date: Tue, 16 Oct 2012 11:34:36 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], Lukas Czerner <[email protected]>
Subject: [PATCH] btrfs: Return EINVAL when length to trim is less than FSBCurrently 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
Quoted 21 lines
Signed-off-by Lukas Czerner <[email protected]>--- fs/btrfs/ioctl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)fs/btrfs/ioctl.c +2
-1@@ -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);
Quoted 8 lines · Lukáš Czerner
Quoted 6 lines · Lukas Czerner
Date: Tue, 16 Oct 2012 11:34:36 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], Lukas Czerner <[email protected]>
Subject: [PATCH] btrfs: Return EINVAL when length to trim is less than FSB
Quoted 7 lines
Quoted 4 lines
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: