* [PATCH] erofs-utils: zero directory writer buffer
@ 2026-09-29 13:39 Garv
2026-09-29 13:42 ` Gao Xiang
0 siblings, 1 reply; 4+ messages in thread
From: Garv @ 2026-09-29 13:39 UTC (permalink / raw)
To: linux-erofs; +Cc: Garv
Signed-off-by: Garv <garvkumar1502@gmail.com>
---
lib/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/inode.c b/lib/inode.c
index ec96556..e7d07e0 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -597,7 +597,7 @@ static struct erofs_vfile *erofs_dirwriter_open(struct erofs_inode *dir)
{
struct erofs_dirwriter_vf *dwv;
- dwv = malloc(sizeof(*dwv) + erofs_blksiz(dir->sbi));
+ dwv = calloc(1, sizeof(*dwv) + erofs_blksiz(dir->sbi));
if (!dwv)
return ERR_PTR(-ENOMEM);
dwv->vf.ops = &erofs_dirwriter_vfops;
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs-utils: zero directory writer buffer
2026-09-29 13:39 [PATCH] erofs-utils: zero directory writer buffer Garv
@ 2026-09-29 13:42 ` Gao Xiang
2026-09-29 18:19 ` Garv Kumar
2026-09-29 18:19 ` Garv Kumar
0 siblings, 2 replies; 4+ messages in thread
From: Gao Xiang @ 2026-09-29 13:42 UTC (permalink / raw)
To: Garv; +Cc: linux-erofs
On Tue, Sep 29, 2026 at 07:09:17PM +0530, Garv wrote:
> Signed-off-by: Garv <garvkumar1502@gmail.com>
Can you explain a bit more why we need that?
Thanks,
Gao Xiang
> ---
> lib/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/inode.c b/lib/inode.c
> index ec96556..e7d07e0 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -597,7 +597,7 @@ static struct erofs_vfile *erofs_dirwriter_open(struct erofs_inode *dir)
> {
> struct erofs_dirwriter_vf *dwv;
>
> - dwv = malloc(sizeof(*dwv) + erofs_blksiz(dir->sbi));
> + dwv = calloc(1, sizeof(*dwv) + erofs_blksiz(dir->sbi));
> if (!dwv)
> return ERR_PTR(-ENOMEM);
> dwv->vf.ops = &erofs_dirwriter_vfops;
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs-utils: zero directory writer buffer
2026-09-29 13:42 ` Gao Xiang
@ 2026-09-29 18:19 ` Garv Kumar
2026-09-29 18:19 ` Garv Kumar
1 sibling, 0 replies; 4+ messages in thread
From: Garv Kumar @ 2026-09-29 18:19 UTC (permalink / raw)
To: Garv, linux-erofs
[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]
Hi Gao,
Thanks for asking. I traced the directory writer path again, and I agree
that my original explanation was incomplete. fill_dirblock() already clears
the unused portion of the generated directory block, so I shouldn’t have
described the change simply as fixing uninitialized directory-block spare
space.
The reproducer I used preserves non-zero contents in the output file by
bypassing the normal truncation path, and the calloc() change makes the
generated image deterministic in that test. However, I have not yet
established that dwv->dirdata is the source of those stale bytes, so I
don’t want to claim that this is the correct fix without further
verification.
I’ll investigate the exact data path and send a revised patch if necessary.
Thanks,
Garv
On Tue, 29 Sept 2026 at 19:12, Gao Xiang <xiang@kernel.org> wrote:
> On Tue, Sep 29, 2026 at 07:09:17PM +0530, Garv wrote:
> > Signed-off-by: Garv <garvkumar1502@gmail.com>
>
> Can you explain a bit more why we need that?
>
> Thanks,
> Gao Xiang
>
> > ---
> > lib/inode.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/inode.c b/lib/inode.c
> > index ec96556..e7d07e0 100644
> > --- a/lib/inode.c
> > +++ b/lib/inode.c
> > @@ -597,7 +597,7 @@ static struct erofs_vfile
> *erofs_dirwriter_open(struct erofs_inode *dir)
> > {
> > struct erofs_dirwriter_vf *dwv;
> >
> > - dwv = malloc(sizeof(*dwv) + erofs_blksiz(dir->sbi));
> > + dwv = calloc(1, sizeof(*dwv) + erofs_blksiz(dir->sbi));
> > if (!dwv)
> > return ERR_PTR(-ENOMEM);
> > dwv->vf.ops = &erofs_dirwriter_vfops;
> > --
> > 2.53.0
> >
> >
>
[-- Attachment #2: Type: text/html, Size: 2883 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs-utils: zero directory writer buffer
2026-09-29 13:42 ` Gao Xiang
2026-09-29 18:19 ` Garv Kumar
@ 2026-09-29 18:19 ` Garv Kumar
1 sibling, 0 replies; 4+ messages in thread
From: Garv Kumar @ 2026-09-29 18:19 UTC (permalink / raw)
To: Garv, linux-erofs
[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]
Hi Gao,
Thanks for asking. I traced the directory writer path again, and I agree
that my original explanation was incomplete. fill_dirblock() already clears
the unused portion of the generated directory block, so I shouldn’t have
described the change simply as fixing uninitialized directory-block spare
space.
The reproducer I used preserves non-zero contents in the output file by
bypassing the normal truncation path, and the calloc() change makes the
generated image deterministic in that test. However, I have not yet
established that dwv->dirdata is the source of those stale bytes, so I
don’t want to claim that this is the correct fix without further
verification.
I’ll investigate the exact data path and send a revised patch if necessary.
Thanks,
Garv
On Tue, 29 Sept 2026 at 19:12, Gao Xiang <xiang@kernel.org> wrote:
> On Tue, Sep 29, 2026 at 07:09:17PM +0530, Garv wrote:
> > Signed-off-by: Garv <garvkumar1502@gmail.com>
>
> Can you explain a bit more why we need that?
>
> Thanks,
> Gao Xiang
>
> > ---
> > lib/inode.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/inode.c b/lib/inode.c
> > index ec96556..e7d07e0 100644
> > --- a/lib/inode.c
> > +++ b/lib/inode.c
> > @@ -597,7 +597,7 @@ static struct erofs_vfile
> *erofs_dirwriter_open(struct erofs_inode *dir)
> > {
> > struct erofs_dirwriter_vf *dwv;
> >
> > - dwv = malloc(sizeof(*dwv) + erofs_blksiz(dir->sbi));
> > + dwv = calloc(1, sizeof(*dwv) + erofs_blksiz(dir->sbi));
> > if (!dwv)
> > return ERR_PTR(-ENOMEM);
> > dwv->vf.ops = &erofs_dirwriter_vfops;
> > --
> > 2.53.0
> >
> >
>
[-- Attachment #2: Type: text/html, Size: 2883 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-29 18:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29 13:39 [PATCH] erofs-utils: zero directory writer buffer Garv
2026-09-29 13:42 ` Gao Xiang
2026-09-29 18:19 ` Garv Kumar
2026-09-29 18:19 ` Garv Kumar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.