summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2024-09-19 12:07:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-14 20:03:36 +0100
commitb6ce2dbe984bcd7fb0c1df15b5e2fa57e1574a8e (patch)
tree59f1518a280c4d74c0e61b633b0c5218b8046051 /crypto
parent2e996ea42ba24fb2829d5e6c6eacd2315439bea9 (diff)
downloadlinux-b6ce2dbe984bcd7fb0c1df15b5e2fa57e1574a8e.tar.gz
linux-b6ce2dbe984bcd7fb0c1df15b5e2fa57e1574a8e.tar.bz2
linux-b6ce2dbe984bcd7fb0c1df15b5e2fa57e1574a8e.zip
ext4: partial zero eof block on unaligned inode size extension
[ Upstream commit c7fc0366c65628fd69bfc310affec4918199aae2 ] Using mapped writes, it's technically possible to expose stale post-eof data on a truncate up operation. Consider the following example: $ xfs_io -fc "pwrite 0 2k" -c "mmap 0 4k" -c "mwrite 2k 2k" \ -c "truncate 8k" -c "pread -v 2k 16" <file> ... 00000800: 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 XXXXXXXXXXXXXXXX ... This shows that the post-eof data written via mwrite lands within EOF after a truncate up. While this is deliberate of the test case, behavior is somewhat unpredictable because writeback does post-eof zeroing, and writeback can occur at any time in the background. For example, an fsync inserted between the mwrite and truncate causes the subsequent read to instead return zeroes. This basically means that there is a race window in this situation between any subsequent extending operation and writeback that dictates whether post-eof data is exposed to the file or zeroed. To prevent this problem, perform partial block zeroing as part of the various inode size extending operations that are susceptible to it. For truncate extension, zero around the original eof similar to how truncate down does partial zeroing of the new eof. For extension via writes and fallocate related operations, zero the newly exposed range of the file to cover any partial zeroing that must occur at the original and new eof blocks. Signed-off-by: Brian Foster <bfoster@redhat.com> Link: https://patch.msgid.link/20240919160741.208162-2-bfoster@redhat.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'crypto')
0 files changed, 0 insertions, 0 deletions