• Boris Burkov's avatar
    btrfs: qgroup: fix qgroup id collision across mounts · 2b8aa78c
    Boris Burkov authored
    If we delete subvolumes whose ID is the largest in the filesystem, then
    unmount and mount again, then btrfs_init_root_free_objectid on the
    tree_root will select a subvolid smaller than that one and thus allow
    reusing it.
    
    If we are also using qgroups (and particularly squotas) it is possible
    to delete the subvol without deleting the qgroup. In that case, we will
    be able to create a new subvol whose id already has a level 0 qgroup.
    This will result in re-using that qgroup which would then lead to
    incorrect accounting.
    
    Fixes: 6ed05643 ("btrfs: create qgroup earlier in snapshot creation")
    CC: stable@vger.kernel.org # 6.7+
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarBoris Burkov <boris@bur.io>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    2b8aa78c
qgroup.c 128 KB