Re: [2.6.33 regression] btrfs mount causes memory corruption
From: Andrew Lutomirski
Date: Thu Feb 25 2010 - 15:48:51 EST
On Thu, Feb 25, 2010 at 3:38 PM, Josef Bacik <josef@xxxxxxxxxx> wrote:
>
> Ok it looks like we have a problem kfree'ing the wrong stuff. we kstrdup the
> options string, but then strsep screws with the pointer, so when we kfree() it,
> we're not giving it the right pointer. Please try this patch, and mount with -o
> acl and other such garbage to make sure it actually worked (acl isn't a valid
> mount option btw). Let me know if it works. Thanks,
>
> Josef
>
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 8a1ea6e..f8b4521 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -128,7 +128,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
> {
> struct btrfs_fs_info *info = root->fs_info;
> substring_t args[MAX_OPT_ARGS];
> - char *p, *num;
> + char *p, *num, *orig;
> int intarg;
> int ret = 0;
>
> @@ -143,6 +143,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
> if (!options)
> return -ENOMEM;
>
> + orig = options;
>
> while ((p = strsep(&options, ",")) != NULL) {
> int token;
> @@ -280,7 +281,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
> }
> }
> out:
> - kfree(options);
> + kfree(orig);
> return ret;
> }
>
>
Thanks for the instant patch. I hammered on it a bit and it hasn't
crashed yet. I'll let you know if it crashes later. (The earlier
trial with xattr crashed after a couple minutes.)
In the mean time,
Tested-by: Andy Lutomirski <luto@xxxxxxx>
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/