multipathd: handle fpin events
Subsystems (2)
PATCH v3 1/1 multipathd: handle fpin events
This patch incorporates the functionality to handle FPIN ELS events present as part of FCTransport daemon (available in EPEL8) into the multipathd. This helps us to reduce the response time to react and take the necessary actions on receiving the FPIN events.
This patch currently support FPIN-Li Events.
It adds a new thread to listen for ELS frames from driver and on receiving the frame payload, push the payload to a list and notify the fpin_els_li_consumer thread to process it.Once consumer thread is notified, it returns to listen for more ELS frames from driver.
The consumer thread process the ELS frames and moves the devices paths which are affected due to link integrity to marginal path groups. This also sets the associated portstate to marginal.
The paths which are set to marginal path group will be unset on receiving the RSCN events
---
Notes:
V3:
Addressed the review comments from Martin
V2:
Removed the newly added config option and added a new value "fpin" to the marginal_pathgroups option.
Added support to handle the multipathd reconfigure case.
Addressed the review comments from Martin
Makefile.inc | 13 + libmultipath/Makefile | 5 + libmultipath/dict.c | 56 +++- libmultipath/libmultipath.version | 1 + libmultipath/propsel.c | 47 ++- libmultipath/structs.h | 7 + multipath/multipath.conf.5 | 19 +- multipathd/Makefile | 10 + multipathd/fpin.h | 20 ++ multipathd/fpin_handlers.c | 540 ++++++++++++++++++++++++++++++ multipathd/main.c | 43 ++- 11 files changed, 745 insertions(+), 16 deletions(-) create mode 100644 multipathd/fpin.h create mode 100644 multipathd/fpin_handlers.c
Makefile.inc +13 -0
@@ -159,6 +159,19 @@ check_file = $(shell \ echo "$$found" \ ) +# Check whether a file contains a variable with name $1 in header file $2 +check_var = $(shell \ + if grep -Eq "(^|[[:blank:]])$1([[:blank:]]|=|$$)" "$2"; then \ + found=1; \ + status="yes"; \ + else \ + found=0; \ + status="no"; \ + fi; \ + echo 1>&2 "Checking for .. $1 in $2 ... $$status"; \ + echo "$$found" \ + ) + %.o: %.c @echo building $@ because of $? $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
libmultipath/Makefile +5 -0
@@ -45,6 +45,11 @@ ifneq ($(call check_func,dm_hold_control_dev,$(DEVMAPPER_INCDIR)/libdevmapper.h) CFLAGS += -DLIBDM_API_HOLD_CONTROL endif +ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/fc_els.h),0) + CFLAGS += -DFPIN_EVENT_HANDLER +endif + + OBJS = parser.o vector.o devmapper.o callout.o \ hwtable.o blacklist.o util.o dmparser.o config.o \ structs.o discovery.o propsel.o dict.o \
libmultipath/dict.c +53 -3
68 lines not on this page · raw message
libmultipath/libmultipath.version +1 -0
@@ -56,6 +56,7 @@ global: check_foreign; cleanup_charp; cleanup_lock; + cleanup_mutex; cleanup_ucharp; close_fd; coalesce_paths;
libmultipath/propsel.c +41 -6
98 lines not on this page · raw message
libmultipath/structs.h +7 -0
@@ -111,6 +111,12 @@ enum find_multipaths_states { __FIND_MULTIPATHS_LAST, }; +enum marginal_pathgroups_mode { +MARGINAL_PATHGROUP_OFF =YN_NO , +MARGINAL_PATHGROUP_ON =YN_YES , +MARGINAL_PATHGROUP_FPIN , +}; +enum flush_states {FLUSH_UNDEF =YNU_UNDEF ,FLUSH_DISABLED =YNU_NO ,
@@ -419,6 +425,7 @@ struct multipath {unsigned char prflag;int all_tg_pt;struct gen_multipath generic_mp; +bool fpin_must_reload; };static inline int marginal_path_check_enabled (const struct multipath *mpp)
multipath/multipath.conf.5 +16 -3
@@ -1088,20 +1088,26 @@ The default is: \fBno\fR . .TP .B marginal_pathgroups -If set to \fIno\fR, the \fIdelay_*_checks\fR, \fImarginal_path_*\fR, and +If set to \fIoff\fR, the \fIdelay_*_checks\fR, \fImarginal_path_*\fR, and \fIsan_path_err_*\fR options will keep marginal, or \(dqshaky\(dq, paths from being reinstated until they have been monitored for some time. This can cause situations where all non-marginal paths are down, and no paths are usable until multipathd detects this and reinstates a marginal path. If the multipath device is not configured to queue IO in this case, it can cause IO errors to occur, even though there are marginal paths available. However, if this -option is set to \fIyes\fR, when one of the marginal path detecting methods +option is set to \fIon\fR, when one of the marginal path detecting methods determines that a path is marginal, it will be reinstated and placed in a separate pathgroup that will only be used after all the non-marginal pathgroups have been tried first. This prevents the possibility of IO errors occurring while marginal paths are still usable. After the path has been monitored for the configured time, and is declared healthy, it will be returned to its -normal pathgroup. See "Shaky paths detection" below for more information. +normal pathgroup. +However if this option is set to \fIfpin\fR multipathd will receive fpin +notifications, set path states to "marginal" accordingly, and regroup paths +as described for "marginal_pathgroups yes". This option can't be used in combination +with other options for "Shaky path detection" (see below).If it is set to fpin, +marginal_path_xyz and san_path_err_xyz parameters are implicitly set to 0. +See "Shaky paths detection" below for more information. .RS .TP The default is: \fBno\fR
@@ -1841,6 +1847,13 @@ increase and the threshold is never reached. Ticks are the time between path checks by multipathd, which is variable and controlled by the \fIpolling_interval\fR and \fImax_polling_interval\fR parameters. . +.TP +.B \(dqFPIN \(dq failure tracking +Fibre channel fabrics can notify hosts about fabric-level issues such +as integrity failures or congestion with so-called Fabric Performance +Impact Notifications (FPINs).On receiving the fpin notifications through ELS +multipathd will move the affected path and port states to marginal. +. .RS 8 .LP This method is \fBdeprecated\fR in favor of the \(dqmarginal_path\(dq failure
multipathd/Makefile +10 -0
@@ -4,6 +4,10 @@ ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0 CFLAGS += -DLIBDM_API_GET_ERRNO endif +ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/fc_els.h),0) + CFLAGS += -DFPIN_EVENT_HANDLER + FPIN_SUPPORT = 1 +endif # # debugging stuff #
@@ -34,6 +38,12 @@ endif OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o waiter.o \ dmevents.o init_unwinder.o +ifeq ($(FPIN_SUPPORT),1) +OBJS += fpin_handlers.o +endif + + + EXEC = multipathd all : $(EXEC)
multipathd/fpin.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __FPIN_H__ +#define __FPIN_H__ + +#ifdef FPIN_EVENT_HANDLER +void *fpin_fabric_notification_receiver (void *unused); +void *fpin_els_li_consumer (void *data); +void fpin_clean_marginal_dev_list (__attribute__((unused))void *arg); +#else +static void *fpin_fabric_notification_receiver (__attribute__((unused))void *unused) +{ +return NULL ; +} +static void *fpin_els_li_consumer (__attribute__((unused))void *data) +{ +return NULL ; +} +/* fpin_clean_marginal_dev_list() is never called */ +#endif + +#endif
multipathd/fpin_handlers.c new file +540 -0
540 lines not on this page · raw message
multipathd/main.c +39 -4
92 lines not on this page · raw message
Signature · 7 lines
2.27.0 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 21 lines · Muneendra Kumar
This patch incorporates the functionality to handle FPIN ELS events present as part of FCTransport daemon (available in EPEL8) into the multipathd. This helps us to reduce the response time to react and take the necessary actions on receiving the FPIN events.
This patch currently support FPIN-Li Events.
It adds a new thread to listen for ELS frames from driver and on receiving the frame payload, push the payload to a list and notify the
fpin_els_li_consumerthread to process it.Once consumer thread is notified, it returns to listen for more ELS frames from driver.The consumer thread process the ELS frames and moves the devices paths
which are affected due to link integrity to marginal path groups. This also sets the associated portstate to marginal. The paths which are set to marginal path group will be unset on receiving the RSCN events
Quoted 3 lines
Signed-off-by Muneendra Kumar <[email protected]>Signed-off-by Benjamin Marzinski <[email protected]>---
Thanks!
Martin
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 26 lines · Martin Wilck
Quoted 21 lines · Muneendra Kumar
This patch incorporates the functionality to handle FPIN ELS events present as part of FCTransport daemon (available in EPEL8) into the multipathd. This helps us to reduce the response time to react and take the necessary actions on receiving the FPIN events.
This patch currently support FPIN-Li Events.
It adds a new thread to listen for ELS frames from driver and on receiving the frame payload, push the payload to a list and notify the
fpin_els_li_consumerthread to process it.Once consumer thread is notified, it returns to listen for more ELS frames from driver.The consumer thread process the ELS frames and moves the devices paths
which are affected due to link integrity to marginal path groups. This also sets the associated portstate to marginal. The paths which are set to marginal path group will be unset on receiving the RSCN eventsQuoted 3 lines
Signed-off-by Muneendra Kumar <[email protected]>Signed-off-by Benjamin Marzinski <[email protected]>---
Quoted 6 lines
Reviewed-by Martin Wilck <[email protected]>Thanks!
Martin
The CI found a minor issue on 32bit, which I'll fixup myself as shown below.
Martin
multipathd/fpin_handlers.c +1 -1
@@ -287,7 +287,7 @@ fpin_parse_li_els_setpath_marginal(uint16_t host_num, struct fc_tlv_desc *tlv, wwpn =be64_to_cpu (li_desc->pname_list[iter]); ret =fpin_chk_wwn_setpath_marginal (host_num, vecs, wwpn);if (ret <0 ) -condlog (2 ,"failed to set the path marginal associated with wwpn: 0x%lx\n" , wwpn); +condlog (2 ,"failed to set the path marginal associated with wwpn: 0x%" PRIx64"\n" , wwpn); count++; }
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 3 lines · Martin Wilck
The CI found a minor issue on 32bit, which I'll fixup myself as shown below.
There are more errors. I'll have another look. Muneendra, you can check this yourself by creating a fork of
https://github.com/openSUSE/multipath-tools and a Pull request against the "queue" branch. While I won't use GH for pulling it, it should run the CI and show you any errors.
Martin
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Hi Muneendra,
coverity found some defects in your patch. Please help me review them, see attachment. It's well possible that they're false positives, but please double-check.
Thanks
Martin
Hi,
Please find the latest report on new defect(s) introduced to mwilck/multipath-tools found with Coverity Scan.
3 new defect(s) introduced to mwilck/multipath-tools found with Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)
** CID 375096: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 161 in fpin_els_add_li_frame()
________________________________________________________________________________________________________
*** CID 375096: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 161 in fpin_els_add_li_frame()
155 pthread_testcancel();
156 els_mrg = calloc(1, sizeof(struct els_marginal_list));
157 if (els_mrg != NULL) {
158 els_mrg->host_num = fc_event->host_no;
159 els_mrg->event_code = fc_event->event_code;
160 els_mrg->length = fc_event->event_datalen;
>>> CID 375096: Memory - corruptions (OVERRUN)
>>> Overrunning buffer pointed to by "&fc_event->event_data" of 4 bytes by passing it to a function which accesses it at byte offset 2047 using argument "fc_event->event_datalen" (which evaluates to 2048). [Note: The source code implementation of the function has been overridden by a builtin model.]
161 memcpy(els_mrg->payload, &(fc_event->event_data), fc_event->event_datalen);
162 list_add_tail(&els_mrg->node, &els_marginal_list_head);
163 pthread_cond_signal(&fpin_li_cond);
164 } else
165 ret = -ENOMEM;
166 pthread_cleanup_pop(1);** CID 375095: Program hangs (LOCK) /multipathd/fpin_handlers.c: 429 in fpin_els_li_consumer()
________________________________________________________________________________________________________
*** CID 375095: Program hangs (LOCK) /multipathd/fpin_handlers.c: 429 in fpin_els_li_consumer()
423 rcu_register_thread();
424 pthread_cleanup_push(fpin_clean_marginal_dev_list, NULL);
425 INIT_LIST_HEAD(&marginal_list_head);
426 pthread_cleanup_push(fpin_clean_els_marginal_list,
427 (void *)&marginal_list_head);
428 for ( ; ; ) {
>>> CID 375095: Program hangs (LOCK)
>>> "pthread_mutex_lock" locks "fpin_li_mutex" while it is locked.
429 pthread_mutex_lock(&fpin_li_mutex);
430 pthread_cleanup_push(cleanup_mutex, &fpin_li_mutex);
431 pthread_testcancel();
432 while (list_empty(&els_marginal_list_head))
433 pthread_cond_wait(&fpin_li_cond, &fpin_li_mutex);434
** CID 375094: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 339 in fpin_handle_els_frame()
________________________________________________________________________________________________________
*** CID 375094: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 339 in fpin_handle_els_frame()
333 struct fc_els_fpin *fpin = (struct fc_els_fpin *)&fc_event->event_data; 334 struct fc_tlv_desc *tlv; 335 uint32_t dtag; 336 337 els_cmd = (uint32_t)fc_event->event_data; 338 tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0]; >>> CID 375094: Memory - corruptions (OVERRUN) >>> "tlv" evaluates to an address that is at byte offset 0 of an array of -4 bytes. 339 dtag = be32_to_cpu(tlv->desc_tag); 340 condlog(4, "Got CMD in add as 0x%x fpin_cmd 0x%x dtag 0x%x\n", 341 els_cmd, fpin->fpin_cmd, dtag);
342
343 if ((fc_event->event_code == FCH_EVT_LINK_FPIN) ||
344 (fc_event->event_code == FCH_EVT_LINKUP) ||
________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yrlXjF1MXVk7PoaBOP4azsLepCe1Mn8gwfBXDBrelSIoRMU8O0U7o5n1FSIQj14Dq4St65JUh9ZnyC-2Fg157qes-2Ft9bX_PKeZaaewXacQHsuZ3T6aIqwwc4cZvX5RuFKlZH-2B-2F-2FW3e6H-2BXHVqahp7aWZNvTEgZriF6MZKau2Bf0lzbvkaTbX4e4aRrLiV588LPwISv-2Baiuvm-2BG4Up9iV7VtAl7qS-2B0T3-2Fqqv361QJbg5iOmqOQvmACpZbC7bxySCtES2vULs1HDMmm0iEnBDbGCNYF1xpA27h3e8fIXqCGYvqwYb-2B3OQ-3D-3D
To manage Coverity Scan email notifications for "[email protected]", click https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yped04pjJnmXOsUBtKYNIXxFPY5t1N6AzTJMa-2BnAWi0npABKE4tMGq7bchotHs-2B2MqcQoJY2TJBjK3IaZ-2BUkHe2wCTAqHQyQFhpCFLiEJ5yDOXcRNksjcYeVNM9nq6-2Fe1c-3DJZ6i_PKeZaaewXacQHsuZ3T6aIqwwc4cZvX5RuFKlZH-2B-2F-2FW3e6H-2BXHVqahp7aWZNvTEgZ8ESLNy-2BD7eSZoQJj9Azw80YJzcErYNLrKcxKMYgGbPxYRwvkDgeGxz4WRfn-2B-2BuPaXZTSYImuaAoKoYTe4RaUajUfXcURMKMcXzDOS6kanowCj0jE9AfLqwwWVbaP-2BgeCbRXyI-2FvgEy6HVXWmfdW8qg-3D-3D
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 3 lines · Martin Wilck
Hi Muneendra,
coverity found some defects in your patch.
I went through them, and found that all were false positives. No need to worry. It was good to have a closer look though.
Martin
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Benjamin Marzinski
maintainerQuoted 33 lines · Martin Wilck
Hi Muneendra,
coverity found some defects in your patch. Please help me review them, see attachment. It's well possible that they're false positives, but please double-check.
Thanks
MartinDate: Thu, 10 Feb 2022 16:50:12 +0000 (UTC)
From: [email protected]
To: [email protected]
Subject: New Defects reported by Coverity Scan for mwilck/multipath-toolsHi,
Please find the latest report on new defect(s) introduced to mwilck/multipath-tools found with Coverity Scan.
3 new defect(s) introduced to mwilck/multipath-tools found with Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)** CID 375096: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 161 in
fpin_els_add_li_frame()________________________________________________________________________________________________________
*** CID 375096: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 161 infpin_els_add_li_frame()
Quoted 8 lines
155 pthread_testcancel();
156 els_mrg = calloc(1, sizeof(struct els_marginal_list));
157 if (els_mrg != NULL) {
158 els_mrg->host_num = fc_event->host_no;
159 els_mrg->event_code = fc_event->event_code;
160 els_mrg->length = fc_event->event_datalen;
>>> CID 375096: Memory - corruptions (OVERRUN)
>>> Overrunning buffer pointed to by "&fc_event->event_data" of 4 bytes by passing it to a function which accesses it at byte offset 2047 using argument "fc_event->event_datalen" (which evaluates to 2048). [Note: The source code implementation of the function has been overridden by a builtin model.]fc_event->event_data is a u32, but that's just because the first 32 bits of the event data is the els_cmd, right? The header makes it clear that event_data actually does hold event_datalen worth of space
Quoted 1 line
From
/usr/include/scsi/scsi_netlink_fc.h
-------------------------------------------
* Note: if Vendor Unique message, &event_data will be start of
* vendor unique payload, and the length of the payload is
* per event_datalen
The only thing that looks possibly suspect here to me is in fpin_fabric_notification_receiver() which calls fpin_els_add_li_frame()
In fpin_fabric_notification_receiver() we guarantee that we read enough for plen to be correct by calling NLMSG_OK(), and we check that plen is big enough to hold fc_event before we start using that. After that, we just assume fc_event is well formed. However we could check that
offsetof(struct fc_nl_event, event_data) + fc_event->event_data_len <= plen
just to make sure that we really read enough space for all the event data.
Quoted 27 lines
161 memcpy(els_mrg->payload, &(fc_event->event_data), fc_event->event_datalen); 162 list_add_tail(&els_mrg->node, &els_marginal_list_head); 163 pthread_cond_signal(&fpin_li_cond); 164 } else 165 ret = -ENOMEM; 166 pthread_cleanup_pop(1);** CID 375095: Program hangs (LOCK) /multipathd/fpin_handlers.c: 429 in
fpin_els_li_consumer()________________________________________________________________________________________________________
*** CID 375095: Program hangs (LOCK) /multipathd/fpin_handlers.c: 429 infpin_els_li_consumer()423 rcu_register_thread(); 424 pthread_cleanup_push(fpin_clean_marginal_dev_list, NULL); 425 INIT_LIST_HEAD(&marginal_list_head); 426 pthread_cleanup_push(fpin_clean_els_marginal_list, 427 (void *)&marginal_list_head); 428 for ( ; ; ) { >>> CID 375095: Program hangs (LOCK) >>> "pthread_mutex_lock" locks "fpin_li_mutex" while it is locked. 429 pthread_mutex_lock(&fpin_li_mutex); 430 pthread_cleanup_push(cleanup_mutex, &fpin_li_mutex); 431 pthread_testcancel(); 432 while (list_empty(&els_marginal_list_head)) 433 pthread_cond_wait(&fpin_li_cond, &fpin_li_mutex);
Quoted 4 lines
434
** CID 375094: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 339 in
fpin_handle_els_frame()
I can't see how we could double lock fpin_li_mutex here. This looks to me like coverity isn't understanding that the pthread_mutex_pop(1) that we must do before we loop is unlocking the mutex.
Quoted 16 lines
________________________________________________________________________________________________________
*** CID 375094: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 339 infpin_handle_els_frame()333 struct fc_els_fpin *fpin = (struct fc_els_fpin *)&fc_event->event_data; 334 struct fc_tlv_desc *tlv; 335 uint32_t dtag; 336 337 els_cmd = (uint32_t)fc_event->event_data; 338 tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0]; >>> CID 375094: Memory - corruptions (OVERRUN) >>> "tlv" evaluates to an address that is at byte offset 0 of an array of -4 bytes. 339 dtag = be32_to_cpu(tlv->desc_tag); 340 condlog(4, "Got CMD in add as 0x%x fpin_cmd 0x%x dtag 0x%x\n", 341 els_cmd, fpin->fpin_cmd, dtag);
Quoted 3 lines
342
343 if ((fc_event->event_code==FCH_EVT_LINK_FPIN) ||
344 (fc_event->event_code==FCH_EVT_LINKUP) ||
Um.. I don't think the array size is really -4 bytes. It's a zero-legth array, and that seems to be tripping up coverity. This looks fine, assuming a well formed fc_event structure. Otherwise we need some checking like
offsetof(struct fc_els_fpin, fpin_desc) + sizeof(struct fc_tlv_desc) <= fc_event->event_data_len
to guarantee that the space actually exists for this.
-Ben
Quoted 7 lines
________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yrlXjF1MXVk7PoaBOP4azsLepCe1Mn8gwfBXDBrelSIoRMU8O0U7o5n1FSIQj14Dq4St65JUh9ZnyC-2Fg157qes-2Ft9bX_PKeZaaewXacQHsuZ3T6aIqwwc4cZvX5RuFKlZH-2B-2F-2FW3e6H-2BXHVqahp7aWZNvTEgZriF6MZKau2Bf0lzbvkaTbX4e4aRrLiV588LPwISv-2Baiuvm-2BG4Up9iV7VtAl7qS-2B0T3-2Fqqv361QJbg5iOmqOQvmACpZbC7bxySCtES2vULs1HDMmm0iEnBDbGCNYF1xpA27h3e8fIXqCGYvqwYb-2B3OQ-3D-3DTo manage Coverity Scan email notifications for "[email protected]", click https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yped04pjJnmXOsUBtKYNIXxFPY5t1N6AzTJMa-2BnAWi0npABKE4tMGq7bchotHs-2B2MqcQoJY2TJBjK3IaZ-2BUkHe2wCTAqHQyQFhpCFLiEJ5yDOXcRNksjcYeVNM9nq6-2Fe1c-3DJZ6i_PKeZaaewXacQHsuZ3T6aIqwwc4cZvX5RuFKlZH-2B-2F-2FW3e6H-2BXHVqahp7aWZNvTEgZ8ESLNy-2BD7eSZoQJj9Azw80YJzcErYNLrKcxKMYgGbPxYRwvkDgeGxz4WRfn-2B-2BuPaXZTSYImuaAoKoYTe4RaUajUfXcURMKMcXzDOS6kanowCj0jE9AfLqwwWVbaP-2BgeCbRXyI-2FvgEy6HVXWmfdW8qg-3D-3D
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Hi Ben,
Quoted 9 lines · Benjamin Marzinski
Quoted 8 lines · Martin Wilck
Hi Muneendra,
coverity found some defects in your patch. Please help me review them,
see attachment. It's well possible that they're false positives, but
please double-check.
Quoted 4 lines
Quoted 3 lines
Thanks
Martin
Thank you. Meanwhile I figured this out myself, and marked the defects as false positives. I've pushed the patch to my "queue" branch. The compilation errors have been resolved, too.
Quoted 109 lines
Quoted 23 lines
Date: Thu, 10 Feb 2022 16:50:12 +0000 (UTC)
From: [email protected]
To: [email protected]
Subject: New Defects reported by Coverity Scan for mwilck/multipath-toolsHi,
Please find the latest report on new defect(s) introduced to mwilck/multipath-tools found with Coverity Scan.
3 new defect(s) introduced to mwilck/multipath-tools found with Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)** CID 375096: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 161 in
fpin_els_add_li_frame()Quoted 18 lines
___________________________________________________________________
_____________________________________
*** CID 375096: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 161 infpin_els_add_li_frame()155 pthread_testcancel();
156 els_mrg =calloc(1, sizeof(struct els_marginal_list));
157 if (els_mrg!= NULL) {
158 els_mrg->host_num =fc_event->host_no; 159 els_mrg->event_code =fc_event->event_code; 160 els_mrg->length =fc_event->event_datalen;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
CID 375096: Memory - corruptions (OVERRUN) Overrunning buffer pointed to by "
&fc_event->event_data" of 4 bytes by passing it to a function which accesses it at byte offset 2047 using argument "fc_event->event_datalen" (which evaluates to 2048). [Note: The source code implementation of the function has been overridden by a builtin model.]
fc_event->event_datais a u32, but that's just because the first 32 bits
of the event data is theels_cmd, right? The header makes it clear thatevent_dataactually does holdevent_datalenworth of spaceFrom
/usr/include/scsi/scsi_netlink_fc.h
-------------------------------------------
* Note: if Vendor Unique message,&event_datawill be start of * vendor unique payload, and the length of the payload is * perevent_datalenThe only thing that looks possibly suspect here to me is in
fpin_fabric_notification_receiver()which callsfpin_els_add_li_frame()In
fpin_fabric_notification_receiver()we guarantee that we read enough
for plen to be correct by callingNLMSG_OK(), and we check that plen is
big enough to holdfc_eventbefore we start using that. After that, we
just assumefc_eventis well formed. However we could check that
offsetof(struct fc_nl_event, event_data)+fc_event->event_data_len<= plenjust to make sure that we really read enough space for all the event data.
Quoted 37 lines
161 memcpy(els_mrg->payload, &(fc_event-
Quoted 1 line
event_data),fc_event->event_datalen);162 list_add_tail(&els_mrg->node,
&els_marginal_list_head);
163 pthread_cond_signal(&fpin_li_cond); 164 } else
165 ret =-ENOMEM;
166 pthread_cleanup_pop(1);** CID 375095: Program hangs (LOCK) /multipathd/fpin_handlers.c: 429 in
fpin_els_li_consumer()___________________________________________________________________
_____________________________________
*** CID 375095: Program hangs (LOCK) /multipathd/fpin_handlers.c: 429 infpin_els_li_consumer()423 rcu_register_thread();
424 pthread_cleanup_push(fpin_clean_marginal_dev_list, NULL);
425 INIT_LIST_HEAD(&marginal_list_head); 426 pthread_cleanup_push(fpin_clean_els_marginal_list, 427 (void *)&marginal_list_head);
428 for ( ; ; ) {Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
CID 375095: Program hangs (LOCK) "
pthread_mutex_lock" locks "fpin_li_mutex" while it is locked.429 pthread_mutex_lock(&fpin_li_mutex); 430 pthread_cleanup_push(cleanup_mutex,
&fpin_li_mutex);
431 pthread_testcancel();
432 while (list_empty(&els_marginal_list_head)) 433 pthread_cond_wait(&fpin_li_cond,&fpin_li_mutex);
434
Quoted 8 lines
Quoted 2 lines
** CID 375094: Memory - corruptions (OVERRUN) /multipathd/fpin_handlers.c: 339 in
fpin_handle_els_frame()I can't see how we could double lock
fpin_li_mutexhere. This looks to me
like coverity isn't understanding that thepthread_mutex_pop(1)that we
must do before we loop is unlocking the mutex.
Exactly.
Martin
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel