Skip to content

Commit

Permalink
btrfs: use after free in btrfs_quota_enable
Browse files Browse the repository at this point in the history
The issue here is that btrfs_commit_transaction() frees "trans" on both
the error and the success path.  So the problem would be if
btrfs_commit_transaction() succeeds, and then qgroup_rescan_init()
fails.  That means that "ret" is non-zero and "trans" is non-NULL and it
leads to a use after free inside the btrfs_end_transaction() macro.

Fixes: 340f1aa ("btrfs: qgroups: Move transaction management inside btrfs_quota_enable/disable")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Dan Carpenter authored and David Sterba committed Aug 23, 2018
1 parent 801660b commit b9b8a41
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,9 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
spin_unlock(&fs_info->qgroup_lock);

ret = btrfs_commit_transaction(trans);
if (ret) {
trans = NULL;
trans = NULL;
if (ret)
goto out_free_path;
}

ret = qgroup_rescan_init(fs_info, 0, 1);
if (!ret) {
Expand Down

0 comments on commit b9b8a41

Please sign in to comment.