]> git.hungrycats.org Git - linux/commit
btrfs: add missing check for nocow and compression inode flags
authorDavid Sterba <dsterba@suse.com>
Fri, 10 Jul 2020 07:49:56 +0000 (09:49 +0200)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 31 Aug 2020 19:16:07 +0000 (15:16 -0400)
commit6283f7436b155cdebbfcf9e7f334b021ad374748
tree03d96fe60e32528fcb0251d5788e18fba7ea63b0
parent31e75fb0fe8785ad2d205b5a8e3644b266c494cb
btrfs: add missing check for nocow and compression inode flags

commit f37c563bab4297024c300b05c8f48430e323809d upstream.

User Forza reported on IRC that some invalid combinations of file
attributes are accepted by chattr.

The NODATACOW and compression file flags/attributes are mutually
exclusive, but they could be set by 'chattr +c +C' on an empty file. The
nodatacow will be in effect because it's checked first in
btrfs_run_delalloc_range.

Extend the flag validation to catch the following cases:

  - input flags are conflicting
  - old and new flags are conflicting
  - initialize the local variable with inode flags after inode ls locked

Inode attributes take precedence over mount options and are an
independent setting.

Nocompress would be a no-op with nodatacow, but we don't want to mix
any compression-related options with nodatacow.

CC: stable@vger.kernel.org # 4.4+
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2f29a31f394ef9cffebbcafcd03db0c8c07f2cd3)
fs/btrfs/ioctl.c