From: Denis V. Lunev <[email protected]>
bio_check_ro() only warns about a write to a read-only disk and lets it
through, and ploop_clone_and_map() passes it on into the mapping code
as on a writable device. Such a write comes from a device stacked on
top, e.g. the partition device that partprobe creates over a ploop
device; a userspace write to the ploop device itself gets EPERM.
Userspace opens the deltas of a read-only table read-only, but the data
of a pio goes to the file through f_op->write_iter() directly, which
does not check FMODE_WRITE, so it reaches the image. Allocating a cluster
punches or zeroes it with vfs_fallocate(), which does, and fails with
EBADF, so part of such a write fails with an I/O error and the rest
changes the read-only image.
Kill write requests of a read-only table in ploop_clone_and_map(), as
dm-qcow2 does since commit 409d7e697578
("drivers/md/dm-qcow2: fail writes to a read-only table"). The write
fails at once with an I/O error and the image stays untouched. Flushes
still pass.
https://virtuozzo.atlassian.net/browse/VSTOR-154096
Reported-by: Denis Genov <[email protected]>
Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <[email protected]>
---
drivers/md/dm-ploop-map.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index b49281691a01..f4b6606127b4 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -2653,6 +2653,9 @@ int ploop_clone_and_map(struct dm_target *ti, struct
request *rq,
return DM_MAPIO_KILL;
}
+ if (op_is_write(req_op(rq)) && ploop_is_ro(ploop))
+ return DM_MAPIO_KILL;
+
if (blk_rq_bytes(rq) && ploop_rq_valid(ploop, rq) < 0)
return DM_MAPIO_KILL;
--
2.53.0
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel