* [dm-devel] [PATCH]dm_get_map: fix segfault when can't found target
@ 2022-05-27 2:27 Wu Guanghao
2022-05-27 19:35 ` Benjamin Marzinski
0 siblings, 1 reply; 3+ messages in thread
From: Wu Guanghao @ 2022-05-27 2:27 UTC (permalink / raw)
To: Christophe Varoqui, Benjamin Marzinski, Martin Wilck,
dm-devel mailing list
Cc: lixiaokeng, linfeilong
We got a segfault when we test multipath + iscsi.
(gdb) bt
#0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
#1 0x00007f694306cd23 in __GI___strdup (s=0x0) at strdup.c:41
#2 0x00007f69433a147c in dm_get_map (name=0x55d4bc090320 "3600140537cde137ea8c43d8a971462c7",
size=size@entry=0x55d4bc0270d8, outparams=outparams@entry=0x7f6941add640) at devmapper.c:688
#3 0x00007f69433cbbdf in update_multipath_table (mpp=mpp@entry=0x55d4bc026f30,
pathvec=pathvec@entry=0x55d4bc063990, flags=flags@entry=0) at structs_vec.c:426
#4 0x00007f69433cbfe5 in update_multipath_strings (mpp=0x55d4bc026f30, pathvec=0x55d4bc063990)
at structs_vec.c:526
#5 0x000055d4bb52e03e in check_path (vecs=0x55d4bbfad760, pp=0x7f692402d270, ticks=<optimized out>)
at main.c:2280
#6 0x000055d4bb52f3e2 in checkerloop (ap=0x55d4bbfad760) at main.c:2542
#7 0x00007f694305b3ba in start_thread (arg=<optimized out>) at pthread_create.c:443
#8 0x00007f69430ddb40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) f 2
#2 0x00007f69433a147c in dm_get_map (name=0x55d4bc090320 "3600140537cde137ea8c43d8a971462c7",
size=size@entry=0x55d4bc0270d8, outparams=outparams@entry=0x7f6941add640) at devmapper.c:688
688 *outparams = strdup(params);
(gdb) l
683 *size = length;
684
685 if (!outparams)
686 r = DMP_OK;
687 else {
688 *outparams = strdup(params);
689 r = *outparams ? DMP_OK : DMP_ERR;
690 }
691
692 out:
(gdb) p params
$1 = 0x0
If can't found target, we should goto out
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
---
libmultipath/devmapper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 2507f77f..450b17ef 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -682,8 +682,8 @@ int dm_get_map(const char *name, unsigned long long *size, char **outparams)
r = DMP_NOT_FOUND;
/* Fetch 1st target */
if (dm_get_next_target(dmt, NULL, &start, &length,
- &target_type, ¶ms) != NULL)
- /* more than one target */
+ &target_type, ¶ms) != NULL || !params)
+ /* more than one target or not found target */
goto out;
if (size)
--
2.27.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [dm-devel] [PATCH]dm_get_map: fix segfault when can't found target
2022-05-27 2:27 [dm-devel] [PATCH]dm_get_map: fix segfault when can't found target Wu Guanghao
@ 2022-05-27 19:35 ` Benjamin Marzinski
2022-05-31 9:57 ` Martin Wilck
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Marzinski @ 2022-05-27 19:35 UTC (permalink / raw)
To: Wu Guanghao
Cc: lixiaokeng, Christophe Varoqui, dm-devel mailing list,
Martin Wilck, linfeilong
On Fri, May 27, 2022 at 10:27:37AM +0800, Wu Guanghao wrote:
> We got a segfault when we test multipath + iscsi.
>
> (gdb) bt
> #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
> #1 0x00007f694306cd23 in __GI___strdup (s=0x0) at strdup.c:41
> #2 0x00007f69433a147c in dm_get_map (name=0x55d4bc090320 "3600140537cde137ea8c43d8a971462c7",
> size=size@entry=0x55d4bc0270d8, outparams=outparams@entry=0x7f6941add640) at devmapper.c:688
> #3 0x00007f69433cbbdf in update_multipath_table (mpp=mpp@entry=0x55d4bc026f30,
> pathvec=pathvec@entry=0x55d4bc063990, flags=flags@entry=0) at structs_vec.c:426
> #4 0x00007f69433cbfe5 in update_multipath_strings (mpp=0x55d4bc026f30, pathvec=0x55d4bc063990)
> at structs_vec.c:526
> #5 0x000055d4bb52e03e in check_path (vecs=0x55d4bbfad760, pp=0x7f692402d270, ticks=<optimized out>)
> at main.c:2280
> #6 0x000055d4bb52f3e2 in checkerloop (ap=0x55d4bbfad760) at main.c:2542
> #7 0x00007f694305b3ba in start_thread (arg=<optimized out>) at pthread_create.c:443
> #8 0x00007f69430ddb40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
> (gdb) f 2
> #2 0x00007f69433a147c in dm_get_map (name=0x55d4bc090320 "3600140537cde137ea8c43d8a971462c7",
> size=size@entry=0x55d4bc0270d8, outparams=outparams@entry=0x7f6941add640) at devmapper.c:688
> 688 *outparams = strdup(params);
> (gdb) l
> 683 *size = length;
> 684
> 685 if (!outparams)
> 686 r = DMP_OK;
> 687 else {
> 688 *outparams = strdup(params);
> 689 r = *outparams ? DMP_OK : DMP_ERR;
> 690 }
> 691
> 692 out:
> (gdb) p params
> $1 = 0x0
>
> If can't found target, we should goto out
>
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
> libmultipath/devmapper.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
> index 2507f77f..450b17ef 100644
> --- a/libmultipath/devmapper.c
> +++ b/libmultipath/devmapper.c
> @@ -682,8 +682,8 @@ int dm_get_map(const char *name, unsigned long long *size, char **outparams)
> r = DMP_NOT_FOUND;
> /* Fetch 1st target */
> if (dm_get_next_target(dmt, NULL, &start, &length,
> - &target_type, ¶ms) != NULL)
> - /* more than one target */
> + &target_type, ¶ms) != NULL || !params)
> + /* more than one target or not found target */
> goto out;
>
> if (size)
> --
> 2.27.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dm-devel] [PATCH]dm_get_map: fix segfault when can't found target
2022-05-27 19:35 ` Benjamin Marzinski
@ 2022-05-31 9:57 ` Martin Wilck
0 siblings, 0 replies; 3+ messages in thread
From: Martin Wilck @ 2022-05-31 9:57 UTC (permalink / raw)
To: Benjamin Marzinski, Wu Guanghao
Cc: lixiaokeng, Christophe Varoqui, dm-devel mailing list, linfeilong
On Fri, 2022-05-27 at 14:35 -0500, Benjamin Marzinski wrote:
> On Fri, May 27, 2022 at 10:27:37AM +0800, Wu Guanghao wrote:
> > We got a segfault when we test multipath + iscsi.
> >
> > (gdb) bt
> > #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-
> > avx2.S:74
> > #1 0x00007f694306cd23 in __GI___strdup (s=0x0) at strdup.c:41
> > #2 0x00007f69433a147c in dm_get_map (name=0x55d4bc090320
> > "3600140537cde137ea8c43d8a971462c7",
> > size=size@entry=0x55d4bc0270d8,
> > outparams=outparams@entry=0x7f6941add640) at devmapper.c:688
> > #3 0x00007f69433cbbdf in update_multipath_table
> > (mpp=mpp@entry=0x55d4bc026f30,
> > pathvec=pathvec@entry=0x55d4bc063990, flags=flags@entry=0) at
> > structs_vec.c:426
> > #4 0x00007f69433cbfe5 in update_multipath_strings
> > (mpp=0x55d4bc026f30, pathvec=0x55d4bc063990)
> > at structs_vec.c:526
> > #5 0x000055d4bb52e03e in check_path (vecs=0x55d4bbfad760,
> > pp=0x7f692402d270, ticks=<optimized out>)
> > at main.c:2280
> > #6 0x000055d4bb52f3e2 in checkerloop (ap=0x55d4bbfad760) at
> > main.c:2542
> > #7 0x00007f694305b3ba in start_thread (arg=<optimized out>) at
> > pthread_create.c:443
> > #8 0x00007f69430ddb40 in clone3 () at
> > ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
> > (gdb) f 2
> > #2 0x00007f69433a147c in dm_get_map (name=0x55d4bc090320
> > "3600140537cde137ea8c43d8a971462c7",
> > size=size@entry=0x55d4bc0270d8,
> > outparams=outparams@entry=0x7f6941add640) at devmapper.c:688
> > 688 *outparams = strdup(params);
> > (gdb) l
> > 683 *size = length;
> > 684
> > 685 if (!outparams)
> > 686 r = DMP_OK;
> > 687 else {
> > 688 *outparams = strdup(params);
> > 689 r = *outparams ? DMP_OK : DMP_ERR;
> > 690 }
> > 691
> > 692 out:
> > (gdb) p params
> > $1 = 0x0
> >
> > If can't found target, we should goto out
> >
> > Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
>
> Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Thanks! Note: We have two other callers of dm_get_next_target that
should add a similar check.
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-31 9:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 2:27 [dm-devel] [PATCH]dm_get_map: fix segfault when can't found target Wu Guanghao
2022-05-27 19:35 ` Benjamin Marzinski
2022-05-31 9:57 ` Martin Wilck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.