Skip to content

Commit b9b8a41

Browse files
Dan Carpenterkdave
authored andcommitted
btrfs: use after free in btrfs_quota_enable
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>
1 parent 801660b commit b9b8a41

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/btrfs/qgroup.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,9 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
10191019
spin_unlock(&fs_info->qgroup_lock);
10201020

10211021
ret = btrfs_commit_transaction(trans);
1022-
if (ret) {
1023-
trans = NULL;
1022+
trans = NULL;
1023+
if (ret)
10241024
goto out_free_path;
1025-
}
10261025

10271026
ret = qgroup_rescan_init(fs_info, 0, 1);
10281027
if (!ret) {

0 commit comments

Comments
 (0)