]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/btrfs-prop-fix-zstd-compression-parameter-validation.patch
Linux 4.14.112
[thirdparty/kernel/stable-queue.git] / queue-4.19 / btrfs-prop-fix-zstd-compression-parameter-validation.patch
1 From 50398fde997f6be8faebdb5f38e9c9c467370f51 Mon Sep 17 00:00:00 2001
2 From: Anand Jain <anand.jain@oracle.com>
3 Date: Tue, 2 Apr 2019 18:07:38 +0800
4 Subject: btrfs: prop: fix zstd compression parameter validation
5
6 From: Anand Jain <anand.jain@oracle.com>
7
8 commit 50398fde997f6be8faebdb5f38e9c9c467370f51 upstream.
9
10 We let pass zstd compression parameter even if it is not fully valid.
11 For example:
12
13 $ btrfs prop set /btrfs compression zst
14 $ btrfs prop get /btrfs compression
15 compression=zst
16
17 zlib and lzo are fine.
18
19 Fix it by checking the correct prefix length.
20
21 Fixes: 5c1aab1dd544 ("btrfs: Add zstd support")
22 CC: stable@vger.kernel.org # 4.14+
23 Reviewed-by: Nikolay Borisov <nborisov@suse.com>
24 Signed-off-by: Anand Jain <anand.jain@oracle.com>
25 Reviewed-by: David Sterba <dsterba@suse.com>
26 Signed-off-by: David Sterba <dsterba@suse.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29 ---
30 fs/btrfs/props.c | 2 +-
31 1 file changed, 1 insertion(+), 1 deletion(-)
32
33 --- a/fs/btrfs/props.c
34 +++ b/fs/btrfs/props.c
35 @@ -396,7 +396,7 @@ static int prop_compression_apply(struct
36 btrfs_set_fs_incompat(fs_info, COMPRESS_LZO);
37 } else if (!strncmp("zlib", value, 4)) {
38 type = BTRFS_COMPRESS_ZLIB;
39 - } else if (!strncmp("zstd", value, len)) {
40 + } else if (!strncmp("zstd", value, 4)) {
41 type = BTRFS_COMPRESS_ZSTD;
42 btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD);
43 } else {