Re: [PATCH] libfs: do not extend i_size when no data was copied

From: Christian Brauner

Date: Fri Oct 30 2026 - 11:08:31 EST


On Sun, 25 Oct 2026 17:11:30 +0000, Hungyu Lin wrote:
> simple_write_end() updates i_size to pos + copied even when copied is
> zero. A failed buffered write past EOF can therefore extend a ramfs file
> without writing any data.
>
> Since prefaulting was moved to the slow write path, this is reproducible
> with a one-byte pwrite() at offset 4096 into an empty ramfs file using an
> unreadable source buffer. The call fails with EFAULT but leaves the file
> size at 4096. generic_perform_write() calls ->write_end() with copied == 0
> before trying to fault in the source buffer.
>
> [...]

Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.5.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc

[1/1] libfs: do not extend i_size when no data was copied
https://git.kernel.org/vfs/vfs/c/4a1edc38b617