diff options
author | Anand Jain <anand.jain@oracle.com> | 2019-04-02 18:07:38 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-17 08:38:51 +0200 |
commit | fbfbb996d58ebf5ddd0c2ae36efcb7015dc50e95 (patch) | |
tree | 00515692a218e39540787724565438e115e3571b /fs | |
parent | 16515acd5bc33e86985fa93ee1b894815e52cdc5 (diff) | |
download | linux-stable-fbfbb996d58ebf5ddd0c2ae36efcb7015dc50e95.tar.gz linux-stable-fbfbb996d58ebf5ddd0c2ae36efcb7015dc50e95.tar.bz2 linux-stable-fbfbb996d58ebf5ddd0c2ae36efcb7015dc50e95.zip |
btrfs: prop: fix zstd compression parameter validation
commit 50398fde997f6be8faebdb5f38e9c9c467370f51 upstream.
We let pass zstd compression parameter even if it is not fully valid.
For example:
$ btrfs prop set /btrfs compression zst
$ btrfs prop get /btrfs compression
compression=zst
zlib and lzo are fine.
Fix it by checking the correct prefix length.
Fixes: 5c1aab1dd544 ("btrfs: Add zstd support")
CC: stable@vger.kernel.org # 4.14+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/props.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c index dc6140013ae8..fd19f3078566 100644 --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c @@ -396,7 +396,7 @@ static int prop_compression_apply(struct inode *inode, btrfs_set_fs_incompat(fs_info, COMPRESS_LZO); } else if (!strncmp("zlib", value, 4)) { type = BTRFS_COMPRESS_ZLIB; - } else if (!strncmp("zstd", value, len)) { + } else if (!strncmp("zstd", value, 4)) { type = BTRFS_COMPRESS_ZSTD; btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD); } else { |