[Acked] [PATCH][SRU][TRUSTY] btrfs: filter invalid arg for btrfs resize
Andy Whitcroft
apw at canonical.com
Tue Mar 24 08:22:17 UTC 2015
On Mon, Mar 23, 2015 at 05:12:55PM +0000, Colin King wrote:
> From: Gui Hecheng <guihc.fnst at cn.fujitsu.com>
>
> BugLink: http://bugs.launchpad.net/bugs/1435441
>
> Originally following cmds will work:
> # btrfs fi resize -10A <mnt>
> # btrfs fi resize -10Gaha <mnt>
> Filter the arg by checking the return pointer of memparse.
>
> Signed-off-by: Gui Hecheng <guihc.fnst at cn.fujitsu.com>
> Signed-off-by: Chris Mason <clm at fb.com>
> (cherry pick from upstream commit 9a40f1222a372de77344d85d31f8fe0e1c0e60e7)
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> fs/btrfs/ioctl.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 5962236..05f8df8 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1472,6 +1472,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
> struct btrfs_trans_handle *trans;
> struct btrfs_device *device = NULL;
> char *sizestr;
> + char *retptr;
> char *devstr = NULL;
> int ret = 0;
> int mod = 0;
> @@ -1539,8 +1540,8 @@ static noinline int btrfs_ioctl_resize(struct file *file,
> mod = 1;
> sizestr++;
> }
> - new_size = memparse(sizestr, NULL);
> - if (new_size == 0) {
> + new_size = memparse(sizestr, &retptr);
> + if (*retptr != '\0' || new_size == 0) {
> ret = -EINVAL;
> goto out_free;
> }
Looks sane, I am not entirely sure if there is anything other than user
convienience here, if bad values could have had bad results. Anyhow,
seems fine:
Acked-by: Andy Whitcroft <apw at canonical.com>
-apw
More information about the kernel-team
mailing list