Re: [PATCH 2/4] btrfs: stop using uninitiazlised fs_info in device_list_add()

Nikolay Borisov
2020-01-14T07:30:10Z

On 14.01.20 г. 8:58 ч., Qu Wenruo wrote:
>
>
> On 2020/1/14 下午2:09, Anand Jain wrote:
>> fs_info is born during mount, and operations before the mount such as
>> scanning and assembling of the device volume should happen without any
>> reference to fs_info.
>>
>> However the patch commit a9261d4125c9 (btrfs: harden agaist duplicate
>> fsid on scanned devices) used fs_info to call btrfs_warn_in_rcu() and
>> btrfs_info_in_rcu(), so if fs_info is NULL, the stacked functions which
>> leads to btrfs_printk() which shall print "unknown" instead of sb->s_id.
>> Or even might UAF as reported in [1].
>
> With your previous patch, which already checked NULL pointer, I didn't
> see the need for NO_FS_INFO.
>
> Or do you believe this calling site is a special?
> If so, I still didn't get the point of NO_FS_INFO, just extra lines
> using __func__ or "during scan: xxxxx" looks enough to me.

I agree with this assessment. What value does NO_FS_INFO bring in
comparison to plain NULL that it warrants a special case?

>
> Thanks,
> Qu
>