All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add_feature: coredump
@ 2016-10-14  2:08 huang.wei56
  2016-10-14  6:02 ` Hannes Reinecke
  2016-10-28 15:14 ` Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: huang.wei56 @ 2016-10-14  2:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: tang.junhui, wei.huang, zhang.kai16, dm-devel

From: "wei.huang" <huang.wei56@zte.com.cn>

Problem:
when we configure device like vendor is COMPELNT in multipath.conf, multipathd will be coredump.

Reasons:
some vonders are not configured features in default_hw. In add_feature, strstr's first parameter *f maybe null.

Signed-off-by: wei.huang <huang.wei56@zte.com.cn>
---
 libmultipath/structs.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index fee58e5..41e142f 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -520,6 +520,20 @@ add_feature (char **f, char *n)
 	if (!n || *n == '0')
 		return 0;
 
+	/* default feature is null */
+	if(!*f)
+	{
+		l = strlen("1 ") + strlen(n) + 1;
+		t = MALLOC(l);
+		if (!t)
+			return 1;
+
+		snprintf(t, l, "1 %s", n);
+		*f = t;
+	
+		return 0;
+	}
+
 	/* Check if feature is already present */
 	if (strstr(*f, n))
 		return 0;
-- 
2.8.1.windows.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] add_feature: coredump
  2016-10-14  2:08 [PATCH] add_feature: coredump huang.wei56
@ 2016-10-14  6:02 ` Hannes Reinecke
  2016-10-17  2:37   ` huang.wei56
  2016-10-28 15:14 ` Bart Van Assche
  1 sibling, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2016-10-14  6:02 UTC (permalink / raw)
  To: huang.wei56, Christophe Varoqui; +Cc: zhang.kai16, dm-devel, tang.junhui

On 10/14/2016 04:08 AM, huang.wei56@zte.com.cn wrote:
> From: "wei.huang" <huang.wei56@zte.com.cn>
> 
> Problem:
> when we configure device like vendor is COMPELNT in multipath.conf, multipathd will be coredump.
> 
> Reasons:
> some vonders are not configured features in default_hw. In add_feature, strstr's first parameter *f maybe null.
> 
> Signed-off-by: wei.huang <huang.wei56@zte.com.cn>
> ---
>  libmultipath/structs.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index fee58e5..41e142f 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -520,6 +520,20 @@ add_feature (char **f, char *n)
>  	if (!n || *n == '0')
>  		return 0;
>  
> +	/* default feature is null */
> +	if(!*f)
> +	{
> +		l = strlen("1 ") + strlen(n) + 1;
> +		t = MALLOC(l);
> +		if (!t)
> +			return 1;
> +
> +		snprintf(t, l, "1 %s", n);
> +		*f = t;
> +	
> +		return 0;
> +	}
> +
>  	/* Check if feature is already present */
>  	if (strstr(*f, n))
>  		return 0;
> 
No, that is wrong.
It'll insert a '1' into the string if no features are present.

I have a patch queued for fixing this one up.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] add_feature: coredump
  2016-10-14  6:02 ` Hannes Reinecke
@ 2016-10-17  2:37   ` huang.wei56
  0 siblings, 0 replies; 5+ messages in thread
From: huang.wei56 @ 2016-10-17  2:37 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, tang.junhui, zhang.kai16


[-- Attachment #1.1: Type: text/plain, Size: 2395 bytes --]

If no features are present, the function will return from the case "if (!n 
|| *n == '0')" ( structs.c line 521) . 

Because add_feature() is called by some functions, taking a protect inside 
is much safer.
 




Hannes Reinecke <hare@suse.de> 
2016-10-14 14:02

收件人
huang.wei56@zte.com.cn, Christophe Varoqui 
<christophe.varoqui@opensvc.com>, 
抄送
bmarzins@redhat.com, dm-devel@redhat.com, zhang.kai16@zte.com.cn, 
tang.junhui@zte.com.cn
主题
Re: [PATCH] add_feature: coredump






On 10/14/2016 04:08 AM, huang.wei56@zte.com.cn wrote:
> From: "wei.huang" <huang.wei56@zte.com.cn>
> 
> Problem:
> when we configure device like vendor is COMPELNT in multipath.conf, 
multipathd will be coredump.
> 
> Reasons:
> some vonders are not configured features in default_hw. In add_feature, 
strstr's first parameter *f maybe null.
> 
> Signed-off-by: wei.huang <huang.wei56@zte.com.cn>
> ---
>  libmultipath/structs.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index fee58e5..41e142f 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -520,6 +520,20 @@ add_feature (char **f, char *n)
>                if (!n || *n == '0')
>                                return 0;
> 
> +              /* default feature is null */
> +              if(!*f)
> +              {
> +                              l = strlen("1 ") + strlen(n) + 1;
> +                              t = MALLOC(l);
> +                              if (!t)
> +                                              return 1;
> +
> +                              snprintf(t, l, "1 %s", n);
> +                              *f = t;
> + 
> +                              return 0;
> +              }
> +
>                /* Check if feature is already present */
>                if (strstr(*f, n))
>                                return 0;
> 
No, that is wrong.
It'll insert a '1' into the string if no features are present.

I have a patch queued for fixing this one up.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                                 Teamlead Storage & 
Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)



[-- Attachment #1.2: Type: text/html, Size: 5287 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] add_feature: coredump
  2016-10-14  2:08 [PATCH] add_feature: coredump huang.wei56
  2016-10-14  6:02 ` Hannes Reinecke
@ 2016-10-28 15:14 ` Bart Van Assche
  2016-11-01  0:53   ` huang.wei56
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2016-10-28 15:14 UTC (permalink / raw)
  To: huang.wei56, Christophe Varoqui; +Cc: zhang.kai16, dm-devel, tang.junhui

On 10/13/2016 07:08 PM, huang.wei56@zte.com.cn wrote:
> From: "wei.huang" <huang.wei56@zte.com.cn>
>
> Problem:
> when we configure device like vendor is COMPELNT in multipath.conf, multipathd will be coredump.
>
> Reasons:
> some vonders are not configured features in default_hw. In add_feature, strstr's first parameter *f maybe null.
>
> Signed-off-by: wei.huang <huang.wei56@zte.com.cn>
> ---
>  libmultipath/structs.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index fee58e5..41e142f 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -520,6 +520,20 @@ add_feature (char **f, char *n)
>  	if (!n || *n == '0')
>  		return 0;
>
> +	/* default feature is null */
> +	if(!*f)
> +	{
> +		l = strlen("1 ") + strlen(n) + 1;
> +		t = MALLOC(l);
> +		if (!t)
> +			return 1;
> +
> +		snprintf(t, l, "1 %s", n);
> +		*f = t;
> +	
> +		return 0;
> +	}
> +
>  	/* Check if feature is already present */
>  	if (strstr(*f, n))
>  		return 0;
>

Hello Wei Huang,

Please use asprintf() instead of open coding it and please also make the 
title of your patch comprehensible. Your patch avoids that multipathd 
triggers a core dump for a certain vendor name but that's not clear from 
the "add_feature: coredump".

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] add_feature: coredump
  2016-10-28 15:14 ` Bart Van Assche
@ 2016-11-01  0:53   ` huang.wei56
  0 siblings, 0 replies; 5+ messages in thread
From: huang.wei56 @ 2016-11-01  0:53 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: dm-devel, tang.junhui, zhang.kai16


[-- Attachment #1.1: Type: text/plain, Size: 2214 bytes --]

Hi Bart,

Thanks for your answer.

I commit the code again with the title "segment faulty occured in 
add_feature()", please review.

Thanks,

Wei huang.



Bart Van Assche <bart.vanassche@sandisk.com> 
2016-10-28 23:14

收件人
<huang.wei56@zte.com.cn>, Christophe Varoqui 
<christophe.varoqui@opensvc.com>, 
抄送
<tang.junhui@zte.com.cn>, <zhang.kai16@zte.com.cn>, <dm-devel@redhat.com>
主题
Re: [dm-devel] [PATCH] add_feature: coredump






On 10/13/2016 07:08 PM, huang.wei56@zte.com.cn wrote:
> From: "wei.huang" <huang.wei56@zte.com.cn>
>
> Problem:
> when we configure device like vendor is COMPELNT in multipath.conf, 
multipathd will be coredump.
>
> Reasons:
> some vonders are not configured features in default_hw. In add_feature, 
strstr's first parameter *f maybe null.
>
> Signed-off-by: wei.huang <huang.wei56@zte.com.cn>
> ---
>  libmultipath/structs.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index fee58e5..41e142f 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -520,6 +520,20 @@ add_feature (char **f, char *n)
>                if (!n || *n == '0')
>                                return 0;
>
> +              /* default feature is null */
> +              if(!*f)
> +              {
> +                              l = strlen("1 ") + strlen(n) + 1;
> +                              t = MALLOC(l);
> +                              if (!t)
> +                                              return 1;
> +
> +                              snprintf(t, l, "1 %s", n);
> +                              *f = t;
> + 
> +                              return 0;
> +              }
> +
>                /* Check if feature is already present */
>                if (strstr(*f, n))
>                                return 0;
>

Hello Wei Huang,

Please use asprintf() instead of open coding it and please also make the 
title of your patch comprehensible. Your patch avoids that multipathd 
triggers a core dump for a certain vendor name but that's not clear from 
the "add_feature: coredump".

Thanks,

Bart.



[-- Attachment #1.2: Type: text/html, Size: 4800 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-01  0:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14  2:08 [PATCH] add_feature: coredump huang.wei56
2016-10-14  6:02 ` Hannes Reinecke
2016-10-17  2:37   ` huang.wei56
2016-10-28 15:14 ` Bart Van Assche
2016-11-01  0:53   ` huang.wei56

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.