]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.35/btrfs-prop-fix-vanished-compression-property-after-failed-set.patch
Linux 4.19.35
[thirdparty/kernel/stable-queue.git] / releases / 4.19.35 / btrfs-prop-fix-vanished-compression-property-after-failed-set.patch
CommitLineData
1dabdb6f
GKH
1From 272e5326c7837697882ce3162029ba893059b616 Mon Sep 17 00:00:00 2001
2From: Anand Jain <anand.jain@oracle.com>
3Date: Tue, 2 Apr 2019 18:07:40 +0800
4Subject: btrfs: prop: fix vanished compression property after failed set
5
6From: Anand Jain <anand.jain@oracle.com>
7
8commit 272e5326c7837697882ce3162029ba893059b616 upstream.
9
10The compression property resets to NULL, instead of the old value if we
11fail to set the new compression parameter.
12
13 $ btrfs prop get /btrfs compression
14 compression=lzo
15 $ btrfs prop set /btrfs compression zli
16 ERROR: failed to set compression for /btrfs: Invalid argument
17 $ btrfs prop get /btrfs compression
18
19This is because the compression property ->validate() is successful for
20'zli' as the strncmp() used the length passed from the userspace.
21
22Fix it by using the expected string length in strncmp().
23
24Fixes: 63541927c8d1 ("Btrfs: add support for inode properties")
25Fixes: 5c1aab1dd544 ("btrfs: Add zstd support")
26CC: stable@vger.kernel.org # 4.14+
27Reviewed-by: Nikolay Borisov <nborisov@suse.com>
28Signed-off-by: Anand Jain <anand.jain@oracle.com>
29Reviewed-by: David Sterba <dsterba@suse.com>
30Signed-off-by: David Sterba <dsterba@suse.com>
31Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32
33---
34 fs/btrfs/props.c | 6 +++---
35 1 file changed, 3 insertions(+), 3 deletions(-)
36
37--- a/fs/btrfs/props.c
38+++ b/fs/btrfs/props.c
39@@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct bt
40
41 static int prop_compression_validate(const char *value, size_t len)
42 {
43- if (!strncmp("lzo", value, len))
44+ if (!strncmp("lzo", value, 3))
45 return 0;
46- else if (!strncmp("zlib", value, len))
47+ else if (!strncmp("zlib", value, 4))
48 return 0;
49- else if (!strncmp("zstd", value, len))
50+ else if (!strncmp("zstd", value, 4))
51 return 0;
52
53 return -EINVAL;