summary refs log tree commit diff
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>2023-01-06 17:43:06 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-24 07:24:33 +0100
commitd3317baa34e99c10c08a8f3280cda062d7112c3a (patch)
tree731287c05c183170bbf14f0d1190875f5bcf64bf /fs/nilfs2
parent87615c0e5351c828888f96e8eb0dd96fff947dad (diff)
downloadlinux-d3317baa34e99c10c08a8f3280cda062d7112c3a.tar.gz
zonefs: Detect append writes at invalid locations
commit a608da3bd730d718f2d3ebec1c26f9865f8f17ce upstream.

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: 02ef12a663c7 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/nilfs2')
0 files changed, 0 insertions, 0 deletions