summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-05-22 15:02:12 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-03 11:21:30 +0200
commitc570525d649f47d2a00379c04436b6706e39ac84 (patch)
treece1949d662aae7384bf7fe2cbd37b4a17df3a9a1 /init
parent64a7976b4f3e6c5d1f7ec069807575ce447198c0 (diff)
Btrfs: fix clone vs chattr NODATASUM race
commit b5c40d598f5408bd0ca22dfffa82f03cd9433f23 upstream. In btrfs_clone_files(), we must check the NODATASUM flag while the inodes are locked. Otherwise, it's possible that btrfs_ioctl_setflags() will change the flags after we check and we can end up with a party checksummed file. The race window is only a few instructions in size, between the if and the locks which is: 3834 if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode)) 3835 return -EISDIR; where the setflags must be run and toggle the NODATASUM flag (provided the file size is 0). The clone will block on the inode lock, segflags takes the inode lock, changes flags, releases log and clone continues. Not impossible but still needs a lot of bad luck to hit unintentionally. Fixes: 0e7b824c4ef9 ("Btrfs: don't make a file partly checksummed through file clone") CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> [ update changelog ] Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [ adjusted for 4.4 ] Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Diffstat (limited to 'init')
0 files changed, 0 insertions, 0 deletions