[PATCH 2/2] erofs: avoid using multiple devices with different type

Sheng Yong shengyong2021 at gmail.com
Wed May 14 20:07:42 AEST 2025


On 5/13/25 23:10, Hongbo Li wrote:
> 
[...]
>>
>> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
>> index 512877d7d855..16b5b1f66584 100644
>> --- a/fs/erofs/super.c
>> +++ b/fs/erofs/super.c
>> @@ -165,8 +165,11 @@ static int erofs_init_device(struct erofs_buf 
>> *buf, struct super_block *sb,
>>                   filp_open(dif->path, O_RDONLY | O_LARGEFILE, 0) :
>>                   bdev_file_open_by_path(dif->path,
>>                           BLK_OPEN_READ, sb->s_type, NULL);
>> -        if (IS_ERR(file))
>> +        if (IS_ERR(file)) {
>> +            if (PTR_ERR(file) == -ENOTBLK)
>> +                file = ERR_PTR(-EINVAL);
>>               return PTR_ERR(file);
> 
> Hi, Yong
> 
> Thank you, I think it is indeed a UAF problem. This fixes the problem 
> introduced by fb176750266a ("erofs: add file-backed mount support"). How 
> about considering adding the fixes tag?

Hi, Hongbo,

Thanks for the comment. Will add a fix tag.
> 
> In addition, I wonder may be we can only check the fc->s_fs_info (we can 
> set it to NULL in .kill_sb) in erofs_fc_get_tree rather than change the 
> error code. So this way we can reback the correct error message to user.

fc is not available in .kill_sb. And in this scenario, fc->s_fs_info is
already set to NULL in get_tree_bdev_flags(primary bdev)=>sget_dev()=>
sget_fc() before fill_super. So we cannot use fc->s_fs_info to indicate
the error.
Since EROFS already handles case of primary=regular & extra=bdev, I
think we could return the same errno (-EINVAL).

thanks,
shengyong

> 
> Thanks,
> Hongbo
> 
>> +        }
>>           if (!erofs_is_fileio_mode(sbi)) {
>>               dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file),
> 



More information about the Linux-erofs mailing list