Re: [PATCH 2/8] btrfs: do not init a reloc root if we aren't relocating

Josef Bacik
2020-03-04T18:47:17Z

On 3/4/20 1:44 PM, Nikolay Borisov wrote:
>
>
> On 4.03.20 г. 18:18 ч., Josef Bacik wrote:
>> We previously were checking if the root had a dead root before accessing
>> root->reloc_root in order to avoid a UAF type bug. However this
>> scenario happens after we've unset the reloc control, so we would have
>> been saved if we'd simply checked for fs_info->reloc_control. At this
>> point during relocation we no longer need to be creating new reloc
>> roots, so simply move this check above the reloc_root checks to avoid
>> any future races and confusion.
>>
>> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
>
>
> Doesn't this patch essentially obviate the reloc_root_is_dead. W.r.t
> ->reloc_ctl it's important to note that it's being set under reloc_mutex
> which this function is also called under so we are guaranteed consistent
> value.
>

Yes it does, but I want to keep the cleanups separate from the fixes. I threw
this in here because it's more of a correctness/fix than a cleanup. Thanks,

Josef