From cfe7312db67fe7561f479c96c242ab7af6046551 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 06 2019 11:00:40 +0000 Subject: import opensm-3.3.21-2.el7 --- diff --git a/.gitignore b/.gitignore index 82bc17c..0e7ac41 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/opensm-3.3.20.tar.gz +SOURCES/opensm-3.3.21.tar.gz diff --git a/.opensm.metadata b/.opensm.metadata index e2a850d..886e1d4 100644 --- a/.opensm.metadata +++ b/.opensm.metadata @@ -1 +1 @@ -5fed27362c1c32ca5a6bb708f3e2d62df22250a2 SOURCES/opensm-3.3.20.tar.gz +4e6bd48c8bb39edec50a078fbd3a1b606be42a47 SOURCES/opensm-3.3.21.tar.gz diff --git a/SOURCES/0001-Use-precision-specifier-for-scanf.patch b/SOURCES/0001-Use-precision-specifier-for-scanf.patch new file mode 100644 index 0000000..25d1ab8 --- /dev/null +++ b/SOURCES/0001-Use-precision-specifier-for-scanf.patch @@ -0,0 +1,44 @@ +From 2b9cf6fe72592379e4be1f2129c8031f0c2b5273 Mon Sep 17 00:00:00 2001 +From: Honggang Li +Date: Fri, 12 Oct 2018 19:54:56 +0800 +Subject: [PATCH] Use precision specifier for scanf + +If user input a string larger than the length of buffer, the stack memory +will be corrupted. + +Signed-off-by: Honggang Li +Signed-off-by: Hal Rosenstock +--- + opensm/main.c | 2 +- + osmtest/osmtest.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/opensm/main.c b/opensm/main.c +index 2d23fe2befef..8def799cea0f 100644 +--- a/opensm/main.c ++++ b/opensm/main.c +@@ -499,7 +499,7 @@ static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid) + fflush(stdout); + if (scanf("%u", &choice) <= 0) { + char junk[128]; +- if (scanf("%s", junk) <= 0) ++ if (scanf("%127s", junk) <= 0) + printf("\nError: Cannot scan!\n"); + } else if (choice == 0) + return 0; +diff --git a/osmtest/osmtest.c b/osmtest/osmtest.c +index 281b247a2e69..fa2e0704b8cc 100644 +--- a/osmtest/osmtest.c ++++ b/osmtest/osmtest.c +@@ -7352,7 +7352,7 @@ osmtest_get_user_port(IN osmtest_t * const p_osmt, + fflush(stdout); + if (scanf("%u", &choice) <= 0) { + char junk[256]; +- if (scanf("%s", junk) <= 0) ++ if (scanf("%255s", junk) <= 0) + printf("\nError: Cannot scan!\n"); + } else if (choice && choice <= num_ports) + break; +-- +2.15.0-rc1 + diff --git a/SOURCES/0002-osm_helper.c-Fix-lsea_str_fixed_width-OVERRUN-issue.patch b/SOURCES/0002-osm_helper.c-Fix-lsea_str_fixed_width-OVERRUN-issue.patch new file mode 100644 index 0000000..edd26e1 --- /dev/null +++ b/SOURCES/0002-osm_helper.c-Fix-lsea_str_fixed_width-OVERRUN-issue.patch @@ -0,0 +1,42 @@ +From c6c7973478c07869b99478b44a6d49db6738b5f0 Mon Sep 17 00:00:00 2001 +From: Honggang Li +Date: Tue, 22 Jan 2019 16:02:54 +0800 +Subject: [PATCH 2/5] osm_helper.c: Fix lsea_str_fixed_width OVERRUN issue + +Issue was found by Coverity. + +When (lsea == IB_LINK_SPEED_EXT_ACTIVE_50 == 4), lsea_str_fixed_width[lsea] +will overrun array. + +Defect type: OVERRUN +4. opensm-3.3.21/opensm/osm_helper.c:3225: cond_at_least: Checking "lsea == 0" implies that "lsea" is at least 1 on the false branch. +6. opensm-3.3.21/opensm/osm_helper.c:3231: cond_between: Checking "lsea > 4" implies that "lsea" is between 1 and 4 (inclusive) on the false branch. +7. opensm-3.3.21/opensm/osm_helper.c:3233: overrun-local: Overrunning array "lsea_str_fixed_width" of 4 8-byte elements at element index 4 (byte offset 32) using index "lsea" (which evaluates to 4). +// 3231| if (lsea > IB_LINK_SPEED_EXT_ACTIVE_50) +// 3232| return lsa_str_fixed_width[3]; +// 3233|-> return lsea_str_fixed_width[lsea]; +// 3234| } +// 3235| + +Signed-off-by: Honggang Li +Signed-off-by: Hal Rosenstock +Signed-off-by: Honggang Li +--- + opensm/osm_helper.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/opensm/osm_helper.c b/opensm/osm_helper.c +index e62775822014..f1219b225703 100644 +--- a/opensm/osm_helper.c ++++ b/opensm/osm_helper.c +@@ -3214,6 +3214,7 @@ static const char *lsea_str_fixed_width[] = { + "Std ", + "14 ", + "25 ", ++ "????", + "50" + }; + +-- +2.15.0-rc1 + diff --git a/SOURCES/0003-osm_helper.c-Make-50-string-proper-fixed-width-in-ls.patch b/SOURCES/0003-osm_helper.c-Make-50-string-proper-fixed-width-in-ls.patch new file mode 100644 index 0000000..c5aa90a --- /dev/null +++ b/SOURCES/0003-osm_helper.c-Make-50-string-proper-fixed-width-in-ls.patch @@ -0,0 +1,28 @@ +From d1cbc9e5309c2009f0d73f4181cd8dde0505cd59 Mon Sep 17 00:00:00 2001 +From: Hal Rosenstock +Date: Tue, 22 Jan 2019 18:23:27 +0200 +Subject: [PATCH 3/5] osm_helper.c: Make "50" string proper fixed width in + lsea_str_fixed_width + +Signed-off-by: Hal Rosenstock +Signed-off-by: Honggang Li +--- + opensm/osm_helper.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/opensm/osm_helper.c b/opensm/osm_helper.c +index f1219b225703..9791172f212c 100644 +--- a/opensm/osm_helper.c ++++ b/opensm/osm_helper.c +@@ -3215,7 +3215,7 @@ static const char *lsea_str_fixed_width[] = { + "14 ", + "25 ", + "????", +- "50" ++ "50 " + }; + + const char *osm_get_lsa_str(IN uint8_t lsa, IN uint8_t lsea, IN uint8_t state, +-- +2.15.0-rc1 + diff --git a/SOURCES/0004-main.c-Remove-NO_EFFECT-code.patch b/SOURCES/0004-main.c-Remove-NO_EFFECT-code.patch new file mode 100644 index 0000000..b302716 --- /dev/null +++ b/SOURCES/0004-main.c-Remove-NO_EFFECT-code.patch @@ -0,0 +1,37 @@ +From bd289653605c39555cf8deb96b6093ec07b8b0dd Mon Sep 17 00:00:00 2001 +From: Honggang Li +Date: Tue, 22 Jan 2019 11:06:30 +0800 +Subject: [PATCH 4/5] main.c: Remove NO_EFFECT code + +Issue was found by Coverity. + +opensm-3.3.21/opensm/main.c:1165: unsigned_compare: This less-than-zero comparison of an unsigned value is never true. "temp < 0U". +// 1163| case 15: +// 1164| temp = strtoul(optarg, NULL, 0); +// 1165|-> if (temp < 0 || temp >= IB_MAX_NUM_VLS) { +// 1166| fprintf(stderr, +// 1167| "ERROR: maximum #VLs for nue routing must be between 0 + +Signed-off-by: Honggang Li +Signed-off-by: Hal Rosenstock +Signed-off-by: Honggang Li +--- + opensm/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/opensm/main.c b/opensm/main.c +index 56bf7d5c588a..9932cd667378 100644 +--- a/opensm/main.c ++++ b/opensm/main.c +@@ -1165,7 +1165,7 @@ int main(int argc, char *argv[]) + break; + case 15: + temp = strtoul(optarg, NULL, 0); +- if (temp < 0 || temp >= IB_MAX_NUM_VLS) { ++ if (temp >= IB_MAX_NUM_VLS) { + fprintf(stderr, + "ERROR: maximum #VLs for nue routing must be between 0 and %d\n", + IB_MAX_NUM_VLS); +-- +2.15.0-rc1 + diff --git a/SOURCES/0005-osm_-link_mgr-trap_rcv-.c-Check-the-return-value-of-.patch b/SOURCES/0005-osm_-link_mgr-trap_rcv-.c-Check-the-return-value-of-.patch new file mode 100644 index 0000000..777e724 --- /dev/null +++ b/SOURCES/0005-osm_-link_mgr-trap_rcv-.c-Check-the-return-value-of-.patch @@ -0,0 +1,111 @@ +From 1da99335fa1b1efd086e537682203ff65a09bed9 Mon Sep 17 00:00:00 2001 +From: Hal Rosenstock +Date: Tue, 22 Jan 2019 11:28:47 +0800 +Subject: [PATCH 5/5] osm_[link_mgr trap_rcv].c: Check the return value of + osm_get_port_by_guid + +Issue was found by Coverity. + +3. Defect type: NULL_RETURNS +8. opensm-3.3.21/opensm/osm_trap_rcv.c:254: returned_null: "osm_get_port_by_guid" returns null (checked 46 out of 49 times). +9. opensm-3.3.21/opensm/osm_trap_rcv.c:254: var_assigned: Assigning: "p_port" = null return value from "osm_get_port_by_guid". +10. opensm-3.3.21/opensm/osm_trap_rcv.c:256: dereference: Dereferencing a null pointer "p_port". +11. opensm-3.3.21/opensm/osm_congestion_control.c:678: example_assign: Example 1: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_cc->subn, port_guid)". +12. opensm-3.3.21/opensm/osm_congestion_control.c:679: example_checked: Example 1 (cont.): "p_port" has its value checked in "p_port". +13. opensm-3.3.21/opensm/osm_drop_mgr.c:91: example_assign: Example 2: Assigning: "p_remote_port" = return value from "osm_get_port_by_guid(sm->p_subn, p_remote_physp->port_guid)". +14. opensm-3.3.21/opensm/osm_drop_mgr.c:94: example_checked: Example 2 (cont.): "p_remote_port" has its value checked in "p_remote_port". +15. opensm-3.3.21/opensm/osm_guid_info_rcv.c:105: example_assign: Example 3: Assigning: "p_port" = return value from "osm_get_port_by_guid(sm->p_subn, port_guid)". +16. opensm-3.3.21/opensm/osm_guid_info_rcv.c:106: example_checked: Example 3 (cont.): "p_port" has its value checked in "p_port". +17. opensm-3.3.21/opensm/osm_inform.c:434: example_assign: Example 4: Assigning: "p_src_port" = return value from "osm_get_port_by_guid(p_subn, source_gid.unicast.interface_id)". +18. opensm-3.3.21/opensm/osm_inform.c:436: example_checked: Example 4 (cont.): "p_src_port" has its value checked in "p_src_port". +19. opensm-3.3.21/opensm/osm_lid_mgr.c:1112: example_assign: Example 5: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_mgr->p_subn, p_mgr->p_subn->sm_port_guid)". +20. opensm-3.3.21/opensm/osm_lid_mgr.c:1114: example_checked: Example 5 (cont.): "p_port" has its value checked in "p_port". +// 1112| p_port = osm_get_port_by_guid(p_mgr->p_subn, +// 1113| p_mgr->p_subn->sm_port_guid); +// 1114|-> if (!p_port) { +// 1115| OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0308: " +// 1116| "Can't acquire SM's port object, GUID 0x%016" PRIx64 + +4. Defect type: NULL_RETURNS +3. opensm-3.3.21/opensm/osm_link_mgr.c:126: returned_null: "osm_get_port_by_guid" returns null (checked 46 out of 49 times). +4. opensm-3.3.21/opensm/osm_link_mgr.c:126: var_assigned: Assigning: "p_port" = null return value from "osm_get_port_by_guid". +5. opensm-3.3.21/opensm/osm_link_mgr.c:128: dereference: Dereferencing a null pointer "p_port". +6. opensm-3.3.21/opensm/osm_congestion_control.c:678: example_assign: Example 1: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_cc->subn, port_guid)". +7. opensm-3.3.21/opensm/osm_congestion_control.c:679: example_checked: Example 1 (cont.): "p_port" has its value checked in "p_port". +8. opensm-3.3.21/opensm/osm_drop_mgr.c:91: example_assign: Example 2: Assigning: "p_remote_port" = return value from "osm_get_port_by_guid(sm->p_subn, p_remote_physp->port_guid)". +9. opensm-3.3.21/opensm/osm_drop_mgr.c:94: example_checked: Example 2 (cont.): "p_remote_port" has its value checked in "p_remote_port". +10. opensm-3.3.21/opensm/osm_guid_info_rcv.c:105: example_assign: Example 3: Assigning: "p_port" = return value from "osm_get_port_by_guid(sm->p_subn, port_guid)". +11. opensm-3.3.21/opensm/osm_guid_info_rcv.c:106: example_checked: Example 3 (cont.): "p_port" has its value checked in "p_port". +12. opensm-3.3.21/opensm/osm_inform.c:434: example_assign: Example 4: Assigning: "p_src_port" = return value from "osm_get_port_by_guid(p_subn, source_gid.unicast.interface_id)". +13. opensm-3.3.21/opensm/osm_inform.c:436: example_checked: Example 4 (cont.): "p_src_port" has its value checked in "p_src_port". +14. opensm-3.3.21/opensm/osm_lid_mgr.c:1112: example_assign: Example 5: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_mgr->p_subn, p_mgr->p_subn->sm_port_guid)". +15. opensm-3.3.21/opensm/osm_lid_mgr.c:1114: example_checked: Example 5 (cont.): "p_port" has its value checked in "p_port". +// 1112| p_port = osm_get_port_by_guid(p_mgr->p_subn, +// 1113| p_mgr->p_subn->sm_port_guid); +// 1114|-> if (!p_port) { +// 1115| OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0308: " +// 1116| "Can't acquire SM's port object, GUID 0x%016" PRIx64 + +Pointed-out-by: Honggang Li + +Signed-off-by: Hal Rosenstock +Signed-off-by: Honggang Li +--- + opensm/osm_link_mgr.c | 2 ++ + opensm/osm_trap_rcv.c | 13 ++++++++++++- + 2 files changed, 14 insertions(+), 1 deletion(-) + +diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c +index 64ddaf7d1560..ca69375378a0 100644 +--- a/opensm/osm_link_mgr.c ++++ b/opensm/osm_link_mgr.c +@@ -112,6 +112,7 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, + OSM_LOG_ENTER(sm->p_log); + + p_node = osm_physp_get_node_ptr(p_physp); ++ CL_ASSERT(p_node); + + p_old_pi = &p_physp->port_info; + +@@ -125,6 +126,7 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, + if (!p_pi->base_lid) { + p_port = osm_get_port_by_guid(sm->p_subn, + osm_physp_get_port_guid(p_physp)); ++ CL_ASSERT(p_port); + p_pi->base_lid = p_port->lid; + sm->lid_mgr.dirty = TRUE; + send_set = TRUE; +diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c +index 51a836981e8c..ba50d9f2fcdb 100644 +--- a/opensm/osm_trap_rcv.c ++++ b/opensm/osm_trap_rcv.c +@@ -253,7 +253,16 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p) + if (!pi->base_lid) { + p_port = osm_get_port_by_guid(sm->p_subn, + osm_physp_get_port_guid(p)); +- pi->base_lid = p_port->lid; ++ if (p_port) ++ pi->base_lid = p_port->lid; ++ else { ++ OSM_LOG(sm->p_log, OSM_LOG_ERROR, ++ "ERR 3804: Port 0x%" PRIx64 ++ " not found, port set failed\n", ++ cl_ntoh64(osm_physp_get_port_guid(p))); ++ status = IB_ERROR; ++ goto EXIT; ++ } + } + pi->master_sm_base_lid = sm->p_subn->sm_base_lid; + } +@@ -263,6 +272,8 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p) + cl_hton32(osm_physp_get_port_num(p)), + FALSE, m_key, + 0, CL_DISP_MSGID_NONE, &context); ++ ++EXIT: + return status; + } + +-- +2.15.0-rc1 + diff --git a/SOURCES/opensm-3.3.13-prefix.patch b/SOURCES/opensm-3.3.13-prefix.patch index 2fe1f41..2446f1c 100644 --- a/SOURCES/opensm-3.3.13-prefix.patch +++ b/SOURCES/opensm-3.3.13-prefix.patch @@ -1,7 +1,8 @@ -diff -up opensm-3.3.18/man/opensm.8.in.prefix opensm-3.3.18/man/opensm.8.in ---- opensm-3.3.18/man/opensm.8.in.prefix 2014-07-04 05:20:36.000000000 -0400 -+++ opensm-3.3.18/man/opensm.8.in 2014-10-17 12:36:56.914220493 -0400 -@@ -11,6 +11,7 @@ opensm \- InfiniBand subnet manager and +diff --git a/man/opensm.8.in b/man/opensm.8.in +index df55768..79e1bfb 100644 +--- a/man/opensm.8.in ++++ b/man/opensm.8.in +@@ -11,6 +11,7 @@ opensm \- InfiniBand subnet manager and administration (SM/SA) [\-g(uid) ] [\-l(mc) ] [\-p(riority) ] @@ -9,12 +10,12 @@ diff -up opensm-3.3.18/man/opensm.8.in.prefix opensm-3.3.18/man/opensm.8.in [\-\-smkey ] [\-\-sm_sl ] [\-r(eassign_lids)] -@@ -135,6 +136,13 @@ This will effect the handover cases, whe +@@ -136,6 +137,13 @@ This will effect the handover cases, where master is chosen by priority and GUID. Range goes from 0 (default and lowest priority) to 15 (highest). .TP +\fB\-\-subnet_prefix\fR -+This option specifies the subnet prefix to use ++This option specifies the subnet prefix to use in +on the fabric. The default prefix is +0xfe80000000000000. OpenMPI in particular requires +separate fabrics plugged into different ports to @@ -23,10 +24,11 @@ diff -up opensm-3.3.18/man/opensm.8.in.prefix opensm-3.3.18/man/opensm.8.in \fB\-\-smkey\fR This option specifies the SM\'s SM_Key (64 bits). This will effect SM authentication. -diff -up opensm-3.3.18/opensm/main.c.prefix opensm-3.3.18/opensm/main.c ---- opensm-3.3.18/opensm/main.c.prefix 2014-07-04 05:06:48.000000000 -0400 -+++ opensm-3.3.18/opensm/main.c 2014-10-17 12:39:33.446663794 -0400 -@@ -160,6 +160,9 @@ static void show_usage(void) +diff --git a/opensm/main.c b/opensm/main.c +index 2d23fe2..b4bb348 100644 +--- a/opensm/main.c ++++ b/opensm/main.c +@@ -161,6 +161,9 @@ static void show_usage(void) " This will effect the handover cases, where master\n" " is chosen by priority and GUID. Range goes\n" " from 0 (lowest priority) to 15 (highest).\n\n"); @@ -36,7 +38,7 @@ diff -up opensm-3.3.18/opensm/main.c.prefix opensm-3.3.18/opensm/main.c printf("--smkey, -k \n" " This option specifies the SM's SM_Key (64 bits).\n" " This will effect SM authentication.\n" -@@ -656,6 +659,7 @@ int main(int argc, char *argv[]) +@@ -665,6 +668,7 @@ int main(int argc, char *argv[]) {"once", 0, NULL, 'o'}, {"reassign_lids", 0, NULL, 'r'}, {"priority", 1, NULL, 'p'}, @@ -44,11 +46,11 @@ diff -up opensm-3.3.18/opensm/main.c.prefix opensm-3.3.18/opensm/main.c {"smkey", 1, NULL, 'k'}, {"routing_engine", 1, NULL, 'R'}, {"ucast_cache", 0, NULL, 'A'}, -@@ -998,6 +1002,11 @@ int main(int argc, char *argv[]) +@@ -1008,6 +1012,11 @@ int main(int argc, char *argv[]) printf(" Priority = %d\n", temp); break; -+ case 15: ++ case 16: + opt.subnet_prefix = cl_hton64(strtoull(optarg, NULL, 16)); + printf(" Subnet_Prefix = <0x%" PRIx64 ">\n", cl_hton64(opt.subnet_prefix)); + break; diff --git a/SPECS/opensm.spec b/SPECS/opensm.spec index 5f3ed8c..64f2fb4 100644 --- a/SPECS/opensm.spec +++ b/SPECS/opensm.spec @@ -1,19 +1,28 @@ %define _hardened_build 1 +%global __remake_config 1 Name: opensm -Version: 3.3.20 -Release: 3%{?dist} +Version: 3.3.21 +Release: 2%{?dist} Summary: OpenIB InfiniBand Subnet Manager and management utilities License: GPLv2 or BSD -Url: http://www.openfabrics.org/ -Source0: http://www.openfabrics.org/downloads/management/%{name}-%{version}.tar.gz +Url: https://github.com/linux-rdma/opensm +Source0: https://github.com/linux-rdma/opensm/releases/download/%{version}/%{name}-%{version}.tar.gz Source2: opensm.logrotate Source4: opensm.sysconfig Source5: opensm.service Source6: opensm.launch Source7: opensm.rwtab Patch0: opensm-3.3.13-prefix.patch -BuildRequires: libibumad-devel, libtool, bison, flex, byacc, systemd +Patch1: 0001-Use-precision-specifier-for-scanf.patch +Patch2: 0002-osm_helper.c-Fix-lsea_str_fixed_width-OVERRUN-issue.patch +Patch3: 0003-osm_helper.c-Make-50-string-proper-fixed-width-in-ls.patch +Patch4: 0004-main.c-Remove-NO_EFFECT-code.patch +Patch5: 0005-osm_-link_mgr-trap_rcv-.c-Check-the-return-value-of-.patch +BuildRequires: libibumad-devel, libtool, bison, flex, byacc, systemd, gcc +%if %{__remake_config} +BuildRequires: libtool, autoconf, automake +%endif Requires: %{name}-libs%{?_isa} = %{version}-%{release}, logrotate, rdma Requires(post): systemd Requires(preun): systemd @@ -48,9 +57,17 @@ Static version of opensm libraries %prep %setup -q -%patch0 -p1 -b .prefix +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 %build +%if %{__remake_config} +./autogen.sh +%endif %configure --with-opensm-conf-sub-dir=rdma CFLAGS="$CFLAGS -fno-strict-aliasing" make %{?_smp_mflags} cd opensm @@ -110,6 +127,14 @@ fi %{_libdir}/lib*.a %changelog +* Wed Feb 13 2019 Honggang Li - 3.3.21-2 +- Fix a few defects +- Resolves: bz1668201 + +* Mon Jan 21 2019 Honggang Li - 3.3.21-1 +- Rebase to latest upstream release 3.3.21 +- Resolves: bz1535978, bz1653660 + * Tue Jun 19 2018 Honggang Li - 3.3.20-3 - Fix BuildRequires - Resolves: bz1567528