WSL2-Linux-Kernel/fs/zonefs
Damien Le Moal a608da3bd7 zonefs: Detect append writes at invalid locations
Using REQ_OP_ZONE_APPEND operations for synchronous writes to sequential
files succeeds regardless of the zone write pointer position, as long as
the target zone is not full. This means that if an external (buggy)
application writes to the zone of a sequential file underneath the file
system, subsequent file write() operation will succeed but the file size
will not be correct and the file will contain invalid data written by
another application.

Modify zonefs_file_dio_append() to check the written sector of an append
write (returned in bio->bi_iter.bi_sector) and return -EIO if there is a
mismatch with the file zone wp offset field. This change triggers a call
to zonefs_io_error() and a zone check. Modify zonefs_io_error_cb() to
not expose the unexpected data after the current inode size when the
errors=remount-ro mode is used. Other error modes are correctly handled
already.

Fixes: 02ef12a663 ("zonefs: use REQ_OP_ZONE_APPEND for sync DIO")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
2023-01-16 08:42:12 +09:00
..
Kconfig zonefs: select CONFIG_CRC32 2021-01-04 09:06:42 +09:00
Makefile zonefs: Export open zone resource information through sysfs 2022-04-21 08:37:51 +09:00
super.c zonefs: Detect append writes at invalid locations 2023-01-16 08:42:12 +09:00
sysfs.c zonefs: Remove to_attr() helper function 2022-11-16 16:08:31 +09:00
trace.h fs/zonefs: Use the enum req_op type for tracing request operations 2022-07-14 12:14:33 -06:00
zonefs.h zonefs: Fix active zone accounting 2022-11-25 17:01:22 +09:00