diff options
author | Anand Jain <anand.jain@oracle.com> | 2015-08-14 06:33:02 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-10-01 11:45:10 -0400 |
commit | 9e271ae27e4407388c5b25c747abc25c07838b0b (patch) | |
tree | c62df5b7fd8cc29c34781a8d207537fbf7c5992d /fs/btrfs/dev-replace.c | |
parent | 12b1c2637b6e0763121648d637ffe603b422e986 (diff) |
Btrfs: kernel operation should come after user input has been verified
By general rule of thumb there shouldn't be any way that user land
could trigger a kernel operation just by sending wrong arguments.
Here do commit cleanups after user input has been verified.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r-- | fs/btrfs/dev-replace.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 7aed8a8ce694..02031fc07f7f 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -327,19 +327,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
327 | args->start.tgtdev_name[0] == '\0') | 327 | args->start.tgtdev_name[0] == '\0') |
328 | return -EINVAL; | 328 | return -EINVAL; |
329 | 329 | ||
330 | /* | ||
331 | * Here we commit the transaction to make sure commit_total_bytes | ||
332 | * of all the devices are updated. | ||
333 | */ | ||
334 | trans = btrfs_attach_transaction(root); | ||
335 | if (!IS_ERR(trans)) { | ||
336 | ret = btrfs_commit_transaction(trans, root); | ||
337 | if (ret) | ||
338 | return ret; | ||
339 | } else if (PTR_ERR(trans) != -ENOENT) { | ||
340 | return PTR_ERR(trans); | ||
341 | } | ||
342 | |||
343 | /* the disk copy procedure reuses the scrub code */ | 330 | /* the disk copy procedure reuses the scrub code */ |
344 | mutex_lock(&fs_info->volume_mutex); | 331 | mutex_lock(&fs_info->volume_mutex); |
345 | ret = btrfs_dev_replace_find_srcdev(root, args->start.srcdevid, | 332 | ret = btrfs_dev_replace_find_srcdev(root, args->start.srcdevid, |
@@ -356,6 +343,19 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
356 | if (ret) | 343 | if (ret) |
357 | return ret; | 344 | return ret; |
358 | 345 | ||
346 | /* | ||
347 | * Here we commit the transaction to make sure commit_total_bytes | ||
348 | * of all the devices are updated. | ||
349 | */ | ||
350 | trans = btrfs_attach_transaction(root); | ||
351 | if (!IS_ERR(trans)) { | ||
352 | ret = btrfs_commit_transaction(trans, root); | ||
353 | if (ret) | ||
354 | return ret; | ||
355 | } else if (PTR_ERR(trans) != -ENOENT) { | ||
356 | return PTR_ERR(trans); | ||
357 | } | ||
358 | |||
359 | btrfs_dev_replace_lock(dev_replace); | 359 | btrfs_dev_replace_lock(dev_replace); |
360 | switch (dev_replace->replace_state) { | 360 | switch (dev_replace->replace_state) { |
361 | case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED: | 361 | case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED: |