[PATCH v2] erofs-utils: lib: fix erofs_iterate_dir() recursion

Jingbo Xu jefflexu at linux.alibaba.com
Sat Jul 22 17:04:23 AEST 2023



On 7/22/23 2:20 PM, Gao Xiang wrote:
> Hi Jingbo,
> 
> On Sat, Jul 22, 2023 at 01:40:09PM +0800, Jingbo Xu wrote:
>> ctx->dir may have changed when ctx is reused along erofs_iterate_dir()
>> recursion.
>>
>> Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
>> ---
>> changes since last version:
>> since traverse_dirents() can be called multiple times in one single
>> erofs_iterate_dir() call, ctx->dir may have changed at the entry of
>> traverse_dirents().  The previous v1 shall be deprecated.
>>
>> v1: https://lore.kernel.org/all/20230718052101.124039-3-jefflexu@linux.alibaba.com/
> 
> I plan to drop this commit directly.  `struct erofs_dir_context` is not
> designed for reusing recursively. It's not the case just due to
> `ctx->dir` but also internal states.
> 
> You need to build another ctx for recursion.

It seems that ctx is reused to avoid stack overflow.  So we have to
allocate ctx on heap to avoid stack overflow?

-- 
Thanks,
Jingbo


More information about the Linux-erofs mailing list