[dm-devel] [PATCH] dm-raid1: fix the parameter passed into the kernel

Lidong Zhong lzhong at suse.com
Wed Apr 15 10:50:38 UTC 2015


If the userspace does not pass the new feature parameter, it will lead
to a kernel crash

Signed-off-by: Lidong Zhong <lzhong at suse.com>
---
 drivers/md/dm-raid1.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 00b1fbd..8e32c4e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -990,6 +990,7 @@ static int parse_features(struct mirror_set *ms, unsigned argc, char **argv,
 	unsigned num_features;
 	struct dm_target *ti = ms->ti;
 	char dummy;
+	int i;
 
 	*args_used = 0;
 
@@ -1010,19 +1011,18 @@ static int parse_features(struct mirror_set *ms, unsigned argc, char **argv,
 		return -EINVAL;
 	}
 
-	if (!strcmp("handle_errors", argv[0]))
-		ms->features |= DM_RAID1_HANDLE_ERRORS;
-	else {
-		ti->error = "Unrecognised feature requested";
-		return -EINVAL;
-	}
-
-	argc--;
-	argv++;
-	(*args_used)++;
+	for (i = 0; i < num_features; i++) {
+		if (!strcmp("handle_errors", argv[0]))
+			ms->features |= DM_RAID1_HANDLE_ERRORS;
+		else if (!strcmp("keep_log", argv[0])) 
+			ms->features |= DM_RAID1_KEEP_LOG;
+		else {
+			ti->error = "Unrecognised feature requested";
+			return -EINVAL;
+		}
 
-	if (!strcmp("keep_log", argv[0])) {
-		ms->features |= DM_RAID1_KEEP_LOG;
+		argc--;
+		argv++;
 		(*args_used)++;
 	}
 
-- 
1.8.1.4




More information about the dm-devel mailing list