diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2013-02-12 11:27:46 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-02-20 12:59:53 -0500 |
commit | bf023ecfcaf114c410759f375073e78b0871c120 (patch) | |
tree | 71498b3d5181414892aaa2a0f632142724968d72 /fs | |
parent | c8f2f24bd56a9f0bc7372e6d6aded6fc122b9120 (diff) |
Btrfs: eliminate a use-after-free in btrfs_balance()
Commit 5af3e8cc introduced a use-after-free at volumes.c:3139: bctl is freed
above in __cancel_balance() in all cases except for balance pause. Fix this
by moving the offending check a couple statements above, the meaning of the
check is preserved.
Reported-by: Chris Mason <chris.mason@fusionio.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 305b6a63ab1f..d778e9666597 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3195,6 +3195,11 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
3195 | mutex_lock(&fs_info->balance_mutex); | 3195 | mutex_lock(&fs_info->balance_mutex); |
3196 | atomic_dec(&fs_info->balance_running); | 3196 | atomic_dec(&fs_info->balance_running); |
3197 | 3197 | ||
3198 | if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { | ||
3199 | fs_info->num_tolerated_disk_barrier_failures = | ||
3200 | btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); | ||
3201 | } | ||
3202 | |||
3198 | if (bargs) { | 3203 | if (bargs) { |
3199 | memset(bargs, 0, sizeof(*bargs)); | 3204 | memset(bargs, 0, sizeof(*bargs)); |
3200 | update_ioctl_balance_args(fs_info, 0, bargs); | 3205 | update_ioctl_balance_args(fs_info, 0, bargs); |
@@ -3205,11 +3210,6 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
3205 | __cancel_balance(fs_info); | 3210 | __cancel_balance(fs_info); |
3206 | } | 3211 | } |
3207 | 3212 | ||
3208 | if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { | ||
3209 | fs_info->num_tolerated_disk_barrier_failures = | ||
3210 | btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); | ||
3211 | } | ||
3212 | |||
3213 | wake_up(&fs_info->balance_wait_q); | 3213 | wake_up(&fs_info->balance_wait_q); |
3214 | 3214 | ||
3215 | return ret; | 3215 | return ret; |