]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: prop: fix vanished compression property after failed set
authorAnand Jain <anand.jain@oracle.com>
Tue, 2 Apr 2019 10:07:40 +0000 (18:07 +0800)
committerDavid Sterba <dsterba@suse.com>
Thu, 4 Apr 2019 15:57:53 +0000 (17:57 +0200)
commitdf0501e36ca9b23edcda58df6da880ec3e4ea615
treebe2f5760d1a6892503ef14f29b564531a0d75671
parentc8bf27a95638a7913bbbb31d9e96b001c87a40fa
btrfs: prop: fix vanished compression property after failed set

The compression property resets to NULL, instead of the old value if we
fail to set the new compression parameter.

  $ btrfs prop get /btrfs compression
    compression=lzo
  $ btrfs prop set /btrfs compression zli
    ERROR: failed to set compression for /btrfs: Invalid argument
  $ btrfs prop get /btrfs compression

This is because the compression property ->validate() is successful for
'zli' as the strncmp() used the length passed from the userspace.

Fix it by using the expected string length in strncmp().

Fixes: de534d81018f ("Btrfs: add support for inode properties")
Fixes: f672bae35bfa ("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>
fs/btrfs/props.c