Re: [Bug report] ext4: EXT4_IOC_MOVE_EXT with len == 0 clamps the length to the whole origin file and overwrites the donor

From: Theodore Tso

Date: Tue Dec 01 2026 - 00:19:08 EST


On Tue, Dec 01, 2026 at 12:40:00AM -0500, Guikun Yang wrote:
> Hi Ted, Jan,
>
> A regular (non-corrupted) ext4 filesystem lets EXT4_IOC_MOVE_EXT with
> me.len == 0 destroy the donor file's data. The ioctl returns 0 with
> moved_len == 1; after a remount the donor file is left empty and
> e2fsck reports a clean filesystem throughout.

Why should we care about the donor file's data? The normal path is
that e4defrag allocates blocks associated with the new donor inode,
and if the donor inode is more contiguous than the target inode, we
then copy the contents of the target inode to the blocks in the donor
inode, and then the those blocks are assigned to the target inode ---
and then e4defrag will delete the the donor inode.

IF the file system gets corrupted, or the data in the target inode is
getting corrupted, that would be really serious. Your bug report is
focused onthe donor inode, and not what is happening with the target
inode. So there may be a problem here, but it appears that it's not
terribly serious. What am I missing?

- Ted