summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortang.junhui <tang.junhui@zte.com.cn>2016-11-04 05:37:09 +0100
committerMike Snitzer <snitzer@redhat.com>2016-11-21 15:52:08 +0100
commitcc5bd925f194c8dc7e2a4eee2c81a4f148018b08 (patch)
tree4d8f3d715414945d7b462dd1e1824ddfa53989e8
parentdm mpath: add m->hw_handler_name NULL pointer check in parse_hw_handler() (diff)
downloadlinux-cc5bd925f194c8dc7e2a4eee2c81a4f148018b08.tar.xz
linux-cc5bd925f194c8dc7e2a4eee2c81a4f148018b08.zip
dm mpath: add checks for priority group count to avoid invalid memory access
This avoids the potential for invalid memory access, if/when there are no priority groups, in response to invalid arguments being sent by the user via DM message (e.g. "switch_group", "disable_group" or "enable_group"). Signed-off-by: tang.junhui <tang.junhui@zte.com.cn> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-mpath.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index d234b6c33646..f8369697af12 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1364,7 +1364,7 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
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 switch_pg_num");
return -EINVAL;
}
@@ -1396,7 +1396,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;
}