hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/zonefs/super.c
....@@ -394,6 +394,10 @@
394394 data_size = zonefs_check_zone_condition(inode, zone,
395395 false, false);
396396 }
397
+ } else if (sbi->s_mount_opts & ZONEFS_MNTOPT_ERRORS_RO &&
398
+ data_size > isize) {
399
+ /* Do not expose garbage data */
400
+ data_size = isize;
397401 }
398402
399403 /*
....@@ -772,6 +776,24 @@
772776
773777 ret = submit_bio_wait(bio);
774778
779
+ /*
780
+ * If the file zone was written underneath the file system, the zone
781
+ * write pointer may not be where we expect it to be, but the zone
782
+ * append write can still succeed. So check manually that we wrote where
783
+ * we intended to, that is, at zi->i_wpoffset.
784
+ */
785
+ if (!ret) {
786
+ sector_t wpsector =
787
+ zi->i_zsector + (zi->i_wpoffset >> SECTOR_SHIFT);
788
+
789
+ if (bio->bi_iter.bi_sector != wpsector) {
790
+ zonefs_warn(inode->i_sb,
791
+ "Corrupted write pointer %llu for zone at %llu\n",
792
+ bio->bi_iter.bi_sector, zi->i_zsector);
793
+ ret = -EIO;
794
+ }
795
+ }
796
+
775797 zonefs_file_write_dio_end_io(iocb, size, ret, 0);
776798
777799 out_release: