[RHEL8,COMMIT] ploop: Increase push backup UUID length

Submitted by Konstantin Khorenko on Oct. 25, 2019, 1:37 p.m.

Details

Message ID 201910251337.x9PDb1GH004157@finist_co8.work.ct
State New
Series "ploop: Increase push backup UUID length"
Headers show

Commit Message

Konstantin Khorenko Oct. 25, 2019, 1:37 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.3
------>
commit 1af69e09da94c83fbe9cdd33ad4bc1cb1f66c36a
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Fri Oct 25 16:37:01 2019 +0300

    ploop: Increase push backup UUID length
    
    Userspace wants keep UUIDs like 203123bc-a64d-44f1-bec8-c50088e11f89,
    so we increase char array length.
    Note, that we don't convert UUID in 4 words of 32bit
    to simplify processing UUID on pb read/write.
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 10 +++++++++-
 drivers/md/dm-ploop.h     |  3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 98e5e0525a1b..1836ac1a3b21 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1,6 +1,7 @@ 
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/uio.h>
+#include <linux/ctype.h>
 #include <linux/umh.h>
 #include "dm-ploop.h"
 
@@ -1351,6 +1352,7 @@  static int ploop_push_backup_start(struct ploop *ploop, char *uuid,
 {
 	struct ploop_cmd cmd = { {0} };
 	struct push_backup *pb;
+	char *p = uuid;
 
 	cmd.type = PLOOP_CMD_SET_PUSH_BACKUP;
 	cmd.ploop = ploop;
@@ -1367,7 +1369,13 @@  static int ploop_push_backup_start(struct ploop *ploop, char *uuid,
 	 */
 	if (!dm_suspended(ploop->ti) || ploop->maintaince)
 		return -EBUSY;
-	if (strlen(uuid) > sizeof(pb->uuid) - 1)
+	/* Check UUID */
+	while (*p) {
+		if (!isxdigit(*p))
+			return -EINVAL;
+		p++;
+	}
+	if (p != uuid + sizeof(pb->uuid) - 1)
 		return -EINVAL;
 	pb = ploop_alloc_pb(ploop, uuid);
 	if (!pb)
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 02b496d7b7c3..1e1ab8ba476e 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -135,7 +135,8 @@  struct ploop_index_wb {
 
 struct push_backup {
 	struct ploop *ploop;
-	u8 uuid[17];
+	/* Store uuid as string and avoid convertation on every read/write */
+	u8 uuid[33];
 	bool alive;
 
 	void *ppb_map;