aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2016-05-04 05:32:00 -0400
committerDavid Sterba <dsterba@suse.com>2016-05-06 09:22:49 -0400
commit7ab19625a911f7568ec85302e3aa7a64186006c8 (patch)
tree2745e636072f4e01263034a77bb434ee93afbb4d
parent48b3b9d401ec86899a52003b37331190a35a81a6 (diff)
btrfs: add write protection to SET_FEATURES ioctl
Perform the want_write check if we get far enough to do any writes. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/ioctl.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 798f58e7338e..1e8ce5247a81 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -5406,9 +5406,15 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
5406 if (ret) 5406 if (ret)
5407 return ret; 5407 return ret;
5408 5408
5409 ret = mnt_want_write_file(file);
5410 if (ret)
5411 return ret;
5412
5409 trans = btrfs_start_transaction(root, 0); 5413 trans = btrfs_start_transaction(root, 0);
5410 if (IS_ERR(trans)) 5414 if (IS_ERR(trans)) {
5411 return PTR_ERR(trans); 5415 ret = PTR_ERR(trans);
5416 goto out_drop_write;
5417 }
5412 5418
5413 spin_lock(&root->fs_info->super_lock); 5419 spin_lock(&root->fs_info->super_lock);
5414 newflags = btrfs_super_compat_flags(super_block); 5420 newflags = btrfs_super_compat_flags(super_block);
@@ -5427,7 +5433,11 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
5427 btrfs_set_super_incompat_flags(super_block, newflags); 5433 btrfs_set_super_incompat_flags(super_block, newflags);
5428 spin_unlock(&root->fs_info->super_lock); 5434 spin_unlock(&root->fs_info->super_lock);
5429 5435
5430 return btrfs_commit_transaction(trans, root); 5436 ret = btrfs_commit_transaction(trans, root);
5437out_drop_write:
5438 mnt_drop_write_file(file);
5439
5440 return ret;
5431} 5441}
5432 5442
5433long btrfs_ioctl(struct file *file, unsigned int 5443long btrfs_ioctl(struct file *file, unsigned int