]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ext4: zero post-EOF partial block before appending write
authorZhang Yi <yi.zhang@huawei.com>
Fri, 27 Mar 2026 10:29:39 +0000 (18:29 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 10 Apr 2026 01:57:52 +0000 (21:57 -0400)
commit3f60efd65412dfe4ff33b376a983220ef74056b1
tree67ceaa2d49a5deb6189ddaf5e1e5ce498fffb99b
parent1ad0f42823291bcac371dafd37533f5e8d92acc3
ext4: zero post-EOF partial block before appending write

In cases of appending write beyond EOF, ext4_zero_partial_blocks() is
called within ext4_*_write_end() to zero out the partial block beyond
EOF. This prevents exposing stale data that might be written through
mmap.

However, supporting only the regular buffered write path is
insufficient. It is also necessary to support the DAX path as well as
the upcoming iomap buffered write path. Therefore, move this operation
to ext4_write_checks().

In addition, this may introduce a race window in which a post-EOF
buffered write can race with an mmap write after the old EOF block has
been zeroed. As a result, the data in this block written by the
buffer-write and the data written by the mmap-write may be mixed.
However, this is safe because users should not rely on the result of the
race condition.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260327102939.1095257-14-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/file.c
fs/ext4/inode.c