OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: khorenko@virtuozzo.com, andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 3/3] dm-ploop: fail writes to a read-only device
Date: Mon,  9 Nov 2026 20:06:04 +0100	[thread overview]
Message-ID: <20261109190604.1850504-4-den@openvz.org> (raw)
In-Reply-To: <20261109190604.1850504-1-den@openvz.org>

From: Denis V. Lunev <den@openvz.org>

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 <denis.genov@virtuozzo.com>
Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 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
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-09 19:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 19:06 [Devel] [PATCH hci-8.1 0/3] dm-ploop: fix writes to a read-only device hanging the host Denis V. Lunev
2026-11-09 19:06 ` [Devel] [PATCH hci-8.1 1/3] dm-ploop: factor out ploop_dispatch_md_waiters() Denis V. Lunev
2026-11-09 19:15   ` no-reply
2026-11-09 19:06 ` [Devel] [PATCH hci-8.1 2/3] dm-ploop: fix pios stuck in md->wait_llist after a failed BAT update Denis V. Lunev
2026-11-09 19:18   ` no-reply
2026-11-09 19:06 ` Denis V. Lunev [this message]
2026-11-09 19:19   ` [Devel] [PATCH hci-8.1 3/3] dm-ploop: fail writes to a read-only device no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261109190604.1850504-4-den@openvz.org \
    --to=den@openvz.org \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox