Skip to content

Directory block spare space is not zeroed #38

@anssih

Description

@anssih

The code in mkfs.erofs does not seem to explicitly zero the spare space left in directory blocks (at least in all cases).

This is normally hidden for normal mkfs.erofs runs by erofs_dev_open() performing ftruncate() (for files) or BLKDISCARD (for block devices) at the beginning of operation, but AFAICS BLKDISCARD does not guarantee that the next read returns zeroes, and that is indeed what I observed in my case. This then breaks image reproducibility.

Attached is a simple patch that adds a hack that allows to simulate non-blkdiscard-zero block devices by skipping ftruncate() on request, and a simple reproducer that first creates an image normally and then again with a "device" prefilled with ones and ftruncate() disabled, resulting in a different image.

reproducer.sh
reproducer.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions