[PATCH v2] erofs-utils: lib: fix erofs_iterate_dir() recursion
Gao Xiang
xiang at kernel.org
Sat Jul 22 17:49:53 AEST 2023
On Sat, Jul 22, 2023 at 03:04:23PM +0800, Jingbo Xu wrote:
>
>
> 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?
It'd be better to use heap space for allocation in principle (even
avoid recursion), but I think it's just some userspace code and
stack space to enough in general.
Thanks,
Gao Xiang
>
> --
> Thanks,
> Jingbo
More information about the Linux-erofs
mailing list