Skip to contentSkip to conversation

dm mpath: add check for count of groups to avoid wild pointer access

PATCH New [email protected] 1 participant 1 message Nov 4, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm mpath: add check for count of groups to avoid wild pointer access

From: "tang.junhui" <[email protected]>

pg is not assigned to a group address when count of multipath groups is zero in bypass_pg_num(), then it is used in bypass_pg(), which may cause wild pointer access.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +1 -1
index e477af8..ab4d716 100644
@@ -1394,7 +1394,7 @@ static int bypass_pg_num(struct multipath *m, const char *pgstr, bool bypassed)
 	char dummy;
 
 	if (!pgstr || (sscanf(pgstr, "%u%c", &pgnum, &dummy) != 1) || !pgnum ||
-	    (pgnum > m->nr_priority_groups)) {
+	    !m->nr_priority_groups || (pgnum > m->nr_priority_groups)) {
 		DMWARN("invalid PG number supplied to bypass_pg");
 		return -EINVAL;
 	}
Signature · 1 line
2.8.1.windows.1