[PATCH] erofs: fix crafted invalid cases for encoded extents

Gao Xiang hsiangkao at linux.alibaba.com
Sat Oct 11 20:10:34 AEDT 2025


Hi Hongbo,

On 2025/10/11 15:37, Hongbo Li wrote:
> Hi Xiang,
> 

...

>> @@ -732,6 +733,10 @@ static int z_erofs_map_sanity_check(struct inode *inode,
>>       if (unlikely(map->m_plen > Z_EROFS_PCLUSTER_MAX_SIZE ||
>>                map->m_llen > Z_EROFS_PCLUSTER_MAX_DSIZE))
>>           return -EOPNOTSUPP;
>> +    /* Filesystems beyond 48-bit physical addresses are invalid */
>> +    if (unlikely(check_add_overflow(map->m_pa, map->m_plen, &pend) ||
>> +             pend >= BIT_ULL(48)))
> 
> Should we consider the non 48-bit block layout which the max is BIT_ULL(32) ?

Non-48bit block layout is strictly limited by the on-disk
__le32, so it's totally impossible to get >= 32-bit
addresses I think it's unnecessary.

but btw, this part is actually wrong, it should be
(pend >> sbi->blkszbits) >= BIT_ULL(48)

I will fix it soon.

Thanks,
Gao Xiang

> 
> Thanks,
> Hongbo
> 
>> +        return -EFSCORRUPTED;
>>       return 0;
>>   }



More information about the Linux-erofs mailing list