dm mpath: add check for count of groups to avoid wild pointer access
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
@@ -1084,7 +1084,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 ; }
Signature · 1 line
2.8.1.windows.1
Quoted 28 lines · On Thu, Nov 03 2016 at 6:49am -0400, [email protected]…
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 inbypass_pg(), which may cause wild pointer access.Signed-off-by tang.junhui <[email protected]>--- drivers/md/dm-mpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-mpath.c +1
-1@@ -1084,7 +1084,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 ; }Signature · 1 line
2.8.1.windows.1
You mention bypass_pg_num() going on to hit a NULL/"wild" pointer. Not immediately seeing the relation between switch_pg_num() and bypass_pg_num(). But shouldn't bypass_pg_num() have improved bounds checking (and/or NULL pointer checks) too?
Maybe your patch was applied with an offset and it modified switch_pg_num() when you really meant to modify bypass_pg_num()?
Hello Mike,
I'm sorry to send you the wrong patch,
I'll send a new patch to you later.
Thanks
Tang
发件人: Mike Snitzer <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected], [email protected] 日期: 2016/11/03 23:33 主题: Re: [dm-devel] dm mpath: add check for count of groups to avoid
wild pointer access
发件人: [email protected]
drivers/md/dm-mpath.c static int switch_pg_num(struct multipath *m,
Quoted 16 lines · On Thu, Nov 03 2016 at 6:49am -0400, [email protected]…
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 inbypass_pg(), which may cause wild pointer access.Signed-off-by tang.junhui <[email protected]>--- drivers/md/dm-mpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-mpath.c +0
-0@@ -1084,7 +1084,7 @@ static int switch_pg_num(struct multipath *m,
const char *pgstr)
drivers/md/dm-mpath.c static int switch_pg_num(struct multipath *m, const char *pgstr)
Quoted 3 lines
drivers/md/dm-mpath.c +0
-0char dummy; if (!pgstr || (sscanf(pgstr, "%u%c", &pgnum, &dummy) !=
1) || !pgnum ||
drivers/md/dm-mpath.c static int switch_pg_num(struct multipath *m, · line 1087
Quoted 2 lines
drivers/md/dm-mpath.c +1
-1- (pgnum > m->nr_priority_groups)) { + !m->nr_priority_groups || (pgnum >
m->nr_priority_groups)) {
drivers/md/dm-mpath.c static int switch_pg_num(struct multipath *m, · line 1088
Quoted 1 line
drivers/md/dm-mpath.c +0
-0DMWARN("invalid PG number supplied to
switch_pg_num");
Quoted 6 lines
drivers/md/dm-mpath.c +0
-0return -EINVAL ; }Signature · 1 line
2.8.1.windows.1
You mention bypass_pg_num() going on to hit a NULL/"wild" pointer. Not immediately seeing the relation between switch_pg_num() and bypass_pg_num(). But shouldn't bypass_pg_num() have improved bounds checking (and/or NULL pointer checks) too?
Maybe your patch was applied with an offset and it modified switch_pg_num() when you really meant to modify bypass_pg_num()?
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel