[05/10] ploop: Prohibit PLOOP_IOC_UPDATE_INDEX on singular list

Submitted by Kirill Tkhai on March 26, 2019, 3:19 p.m.

Details

Message ID 155361354283.12708.5066044264810316558.stgit@localhost.localdomain
State New
Series "ploop: Discard with zeroing of ploop1 indexes support"
Headers show

Commit Message

Kirill Tkhai March 26, 2019, 3:19 p.m.
Add debug check to not miss a moment userspace
decides to change its behavior.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 11bc864a5679..57920a93129a 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4277,7 +4277,14 @@  static int ploop_index_update_ioc(struct ploop_device *plo, unsigned long arg)
 	struct reloc_map *map;
 	int i;
 
-	if (list_empty(&plo->map.delta_list))
+	/*
+	 * Currently this is used by userspace for relocation
+	 * of start blocks before expanding BAT of !top delta.
+	 * In case of someone wants to do that on a singular
+	 * list, he should expand holes bitmap too.
+	 */
+	if (list_empty(&plo->map.delta_list) ||
+	    list_is_singular(&plo->map.delta_list))
 		return -ENOENT;
 
 	if (copy_from_user(&ctl, (void*)arg,