erofs-utils: zero directory writer buffer
PATCH 1/1 erofs-utils: zero directory writer buffer
--- lib/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/inode.c +1 -1
@@ -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;
Signature · 1 line
2.53.0
Quoted 1 line · Garv
Signed-off-by Garv <[email protected]>
Can you explain a bit more why we need that?
Thanks,
Gao Xiang
Quoted 21 lines
--- lib/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/inode.c +1
-1@@ -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;Signature · 1 line
2.53.0
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
Quoted 31 lines · Gao Xiang
Quoted 1 line · Garv
Signed-off-by Garv <[email protected]>Can you explain a bit more why we need that?
Thanks,
Gao Xianglib/inode.c static struct erofs_vfile
Quoted 9 lines
--- lib/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/inode.c +0
-0@@ -597,7 +597,7 @@ static struct erofs_vfile*erofs_dirwriter_open(struct
erofs_inode*dir)Quoted 12 lines
lib/inode.c +1
-2{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
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
Quoted 31 lines · Gao Xiang
Quoted 1 line · Garv
Signed-off-by Garv <[email protected]>Can you explain a bit more why we need that?
Thanks,
Gao Xianglib/inode.c static struct erofs_vfile
Quoted 9 lines
--- lib/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/inode.c +0
-0@@ -597,7 +597,7 @@ static struct erofs_vfile*erofs_dirwriter_open(struct
erofs_inode*dir)Quoted 12 lines
lib/inode.c +1
-2{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