[RHEL8,COMMIT] ploop: Prohibit flip on raw delta

Submitted by Konstantin Khorenko on Dec. 10, 2019, 3:12 p.m.

Details

Message ID 201912101512.xBAFC4rP023798@finist_co8.work.ct
State New
Series "ploop: Prohibit flip on raw delta"
Headers show

Commit Message

Konstantin Khorenko Dec. 10, 2019, 3:12 p.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.2.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.2.6
------>
commit 4fd27a8667ca1269cf33fe465b990b01d2751927
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Dec 10 18:12:04 2019 +0300

    ploop: Prohibit flip on raw delta
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index c57d2187c634..8081b4d89ba2 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -580,6 +580,7 @@  int ploop_add_delta(struct ploop *ploop, const char *arg)
 		is_raw = true;
 		arg += 4;
 	}
+	/* Only ploop->deltas[0] may be raw */
 	if (level == BAT_LEVEL_TOP || (is_raw && level))
 		return -EMFILE;
 	if (kstrtos32(arg, 10, &fd) < 0)
@@ -1243,13 +1244,14 @@  static int ploop_flip_upper_deltas(struct ploop *ploop, char *new_dev,
 	cmd.type = PLOOP_CMD_FLIP_UPPER_DELTAS;
 	cmd.ploop = ploop;
 
-	/* FIXME: prohibit flip on raw delta */
 	if (!dm_suspended(ti) || !ploop->noresume || ploop->maintaince)
 		return -EBUSY;
 	if (ploop_is_ro(ploop))
 		return -EROFS;
 	if (!ploop->nr_deltas)
 		return -ENOENT;
+	if (ploop->deltas[ploop->nr_deltas - 1].is_raw)
+		return -EBADSLT;
 	if (kstrtou32(new_ro_fd, 10, &new_fd) < 0 ||
 	    !(cmd.flip_upper_deltas.file = fget(new_fd)))
 		return -EBADF;