deepin-kernel/fs/affs
Simon Tatham 5ecc33b454 affs: don't write overlarge OFS data block size fields
[ Upstream commit 011ea742a2 ]

If a data sector on an OFS floppy contains a value > 0x1e8 (the
largest amount of data that fits in the sector after its header), then
an Amiga reading the file can return corrupt data, by taking the
overlarge size at its word and reading past the end of the buffer it
read the disk sector into!

The cause: when affs_write_end_ofs() writes data to an OFS filesystem,
the new size field for a data block was computed by adding the amount
of data currently being written (into the block) to the existing value
of the size field. This is correct if you're extending the file at the
end, but if you seek backwards in the file and overwrite _existing_
data, it can lead to the size field being larger than the maximum
legal value.

This commit changes the calculation so that it sets the size field to
the max of its previous size and the position within the block that we
just wrote up to.

Signed-off-by: Simon Tatham <anakin@pobox.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 54fd5a5b7583f1964a79e9efe02e30e97b61eb95)
2025-04-14 15:49:35 +08:00
..
Changes
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
affs.h fs: port ->rename() to pass mnt_idmap 2023-01-19 09:24:26 +01:00
amigaffs.c affs: convert to ctime accessor functions 2023-07-13 10:28:03 +02:00
amigaffs.h fs: affs: Initialize filesystem timestamp ranges 2019-08-30 07:27:18 -07:00
bitmap.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
dir.c iversion: Rename make inode_cmp_iversion{+raw} to inode_eq_iversion{+raw} 2018-02-01 08:15:25 -05:00
file.c affs: don't write overlarge OFS data block size fields 2025-04-14 15:49:35 +08:00
inode.c affs: convert to ctime accessor functions 2023-07-13 10:28:03 +02:00
namei.c affs: rename local toupper() to fn() to avoid confusion 2023-08-22 14:20:10 +02:00
super.c affs: move from strlcpy with unused retval to strscpy 2022-08-19 13:03:10 +02:00
symlink.c affs: convert affs_symlink_read_folio() to use the folio 2023-08-18 10:12:29 -07:00