diff --git a/SOURCES/0009-CVE-2020-5208.patch b/SOURCES/0009-CVE-2020-5208.patch new file mode 100644 index 0000000..ab92493 --- /dev/null +++ b/SOURCES/0009-CVE-2020-5208.patch @@ -0,0 +1,383 @@ +From a1732e68bce148255785e67eb035520729274d86 Mon Sep 17 00:00:00 2001 +From: Chrostoper Ertl +Date: Thu, 28 Nov 2019 16:33:59 +0000 +Subject: [PATCH] Fixes for CVE-2020-5208 + +see https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp + +This patch is combination of following commits: + +pick e824c23316ae50beb7f7488f2055ac65e8b341f2 fru: Fix buffer overflow vulnerabilities +pick 840fb1cbb4fb365cb9797300e3374d4faefcdb10 fru: Fix buffer overflow in ipmi_spd_print_fru +pick 41d7026946fafbd4d1ec0bcaca3ea30a6e8eed22 session: Fix buffer overflow in ipmi_get_session_info +pick 9452be87181a6e83cfcc768b3ed8321763db50e4 channel: Fix buffer overflow +pick d45572d71e70840e0d4c50bf48218492b79c1a10 lanp: Fix buffer overflows in get_lan_param_select +pick 7ccea283dd62a05a320c1921e3d8d71a87772637 fru, sdr: Fix id_string buffer overflows + +[vdolezal@redhat.com]: fixed memleak of `spd_data` in + lib/dimm_spd.c:ipmi_spd_print_fru() +--- + lib/dimm_spd.c | 11 ++++++++++- + lib/ipmi_channel.c | 5 ++++- + lib/ipmi_fru.c | 35 ++++++++++++++++++++++++++++++++--- + lib/ipmi_lanp.c | 14 +++++++------- + lib/ipmi_sdr.c | 40 ++++++++++++++++++++++++---------------- + lib/ipmi_session.c | 12 ++++++++---- + 6 files changed, 85 insertions(+), 32 deletions(-) + +diff --git a/lib/dimm_spd.c b/lib/dimm_spd.c +index 41e30db..ebcc94c 100644 +--- a/lib/dimm_spd.c ++++ b/lib/dimm_spd.c +@@ -1621,7 +1621,7 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id) + struct ipmi_rq req; + struct fru_info fru; + uint8_t *spd_data, msg_data[4]; +- int len, offset; ++ uint32_t len, offset; + + msg_data[0] = id; + +@@ -1697,6 +1697,15 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id) + } + + len = rsp->data[0]; ++ if(rsp->data_len < 1 ++ || len > rsp->data_len - 1 ++ || len > fru.size - offset) ++ { ++ printf(" Not enough buffer size"); ++ free(spd_data); ++ spd_data = NULL; ++ return -1; ++ } + memcpy(&spd_data[offset], rsp->data + 1, len); + offset += len; + } while (offset < fru.size); +diff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c +index 3ae3104..80ba522 100644 +--- a/lib/ipmi_channel.c ++++ b/lib/ipmi_channel.c +@@ -447,7 +447,10 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type, + lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites"); + return -1; + } +- if (rsp->ccode || rsp->data_len < 1) { ++ if (rsp->ccode ++ || rsp->data_len < 1 ++ || rsp->data_len > sizeof(uint8_t) + MAX_CIPHER_SUITE_DATA_LEN) ++ { + lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s", + val2str(rsp->ccode, completion_code_vals)); + return -1; +diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c +index cf00eff..98bc984 100644 +--- a/lib/ipmi_fru.c ++++ b/lib/ipmi_fru.c +@@ -615,7 +615,10 @@ int + read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + uint32_t offset, uint32_t length, uint8_t *frubuf) + { +- uint32_t off = offset, tmp, finish; ++ uint32_t off = offset; ++ uint32_t tmp; ++ uint32_t finish; ++ uint32_t size_left_in_buffer; + struct ipmi_rs * rsp; + struct ipmi_rq req; + uint8_t msg_data[4]; +@@ -628,10 +631,12 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + + finish = offset + length; + if (finish > fru->size) { ++ memset(frubuf + fru->size, 0, length - fru->size); + finish = fru->size; + lprintf(LOG_NOTICE, "Read FRU Area length %d too large, " + "Adjusting to %d", + offset + length, finish - offset); ++ length = finish - offset; + } + + memset(&req, 0, sizeof(req)); +@@ -667,6 +672,7 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + } + } + ++ size_left_in_buffer = length; + do { + tmp = fru->access ? off >> 1 : off; + msg_data[0] = id; +@@ -707,9 +713,18 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + } + + tmp = fru->access ? rsp->data[0] << 1 : rsp->data[0]; ++ if(rsp->data_len < 1 ++ || tmp > rsp->data_len - 1 ++ || tmp > size_left_in_buffer) ++ { ++ printf(" Not enough buffer size"); ++ return -1; ++ } ++ + memcpy(frubuf, rsp->data + 1, tmp); + off += tmp; + frubuf += tmp; ++ size_left_in_buffer -= tmp; + /* sometimes the size returned in the Info command + * is too large. return 0 so higher level function + * still attempts to parse what was returned */ +@@ -742,7 +757,9 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + uint32_t offset, uint32_t length, uint8_t *frubuf) + { + static uint32_t fru_data_rqst_size = 20; +- uint32_t off = offset, tmp, finish; ++ uint32_t off = offset; ++ uint32_t tmp, finish; ++ uint32_t size_left_in_buffer; + struct ipmi_rs * rsp; + struct ipmi_rq req; + uint8_t msg_data[4]; +@@ -755,10 +772,12 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + + finish = offset + length; + if (finish > fru->size) { ++ memset(frubuf + fru->size, 0, length - fru->size); + finish = fru->size; + lprintf(LOG_NOTICE, "Read FRU Area length %d too large, " + "Adjusting to %d", + offset + length, finish - offset); ++ length = finish - offset; + } + + memset(&req, 0, sizeof(req)); +@@ -773,6 +792,8 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + if (fru->access && fru_data_rqst_size > 16) + #endif + fru_data_rqst_size = 16; ++ ++ size_left_in_buffer = length; + do { + tmp = fru->access ? off >> 1 : off; + msg_data[0] = id; +@@ -804,8 +825,16 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, + } + + tmp = fru->access ? rsp->data[0] << 1 : rsp->data[0]; ++ if(rsp->data_len < 1 ++ || tmp > rsp->data_len - 1 ++ || tmp > size_left_in_buffer) ++ { ++ printf(" Not enough buffer size"); ++ return -1; ++ } + memcpy((frubuf + off)-offset, rsp->data + 1, tmp); + off += tmp; ++ size_left_in_buffer -= tmp; + + /* sometimes the size returned in the Info command + * is too large. return 0 so higher level function +@@ -3033,7 +3062,7 @@ ipmi_fru_print(struct ipmi_intf * intf, struct sdr_record_fru_locator * fru) + return 0; + + memset(desc, 0, sizeof(desc)); +- memcpy(desc, fru->id_string, fru->id_code & 0x01f); ++ memcpy(desc, fru->id_string, __min(fru->id_code & 0x01f, sizeof(desc))); + desc[fru->id_code & 0x01f] = 0; + printf("FRU Device Description : %s (ID %d)\n", desc, fru->device_id); + +diff --git a/lib/ipmi_lanp.c b/lib/ipmi_lanp.c +index 65d881b..022c7f1 100644 +--- a/lib/ipmi_lanp.c ++++ b/lib/ipmi_lanp.c +@@ -1809,7 +1809,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + /* set new ipaddr */ + memcpy(data+3, temp, 4); + printf("Setting LAN Alert %d IP Address to %d.%d.%d.%d\n", alert, +@@ -1824,7 +1824,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + /* set new macaddr */ + memcpy(data+7, temp, 6); + printf("Setting LAN Alert %d MAC Address to " +@@ -1838,7 +1838,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + + if (strncasecmp(argv[1], "def", 3) == 0 || + strncasecmp(argv[1], "default", 7) == 0) { +@@ -1864,7 +1864,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + + if (strncasecmp(argv[1], "on", 2) == 0 || + strncasecmp(argv[1], "yes", 3) == 0) { +@@ -1889,7 +1889,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + + if (strncasecmp(argv[1], "pet", 3) == 0) { + printf("Setting LAN Alert %d destination to PET Trap\n", alert); +@@ -1917,7 +1917,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + + if (str2uchar(argv[1], &data[2]) != 0) { + lprintf(LOG_ERR, "Invalid time: %s", argv[1]); +@@ -1933,7 +1933,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert, + if (p == NULL) { + return (-1); + } +- memcpy(data, p->data, p->data_len); ++ memcpy(data, p->data, __min(p->data_len, sizeof(data))); + + if (str2uchar(argv[1], &data[3]) != 0) { + lprintf(LOG_ERR, "Invalid retry: %s", argv[1]); +diff --git a/lib/ipmi_sdr.c b/lib/ipmi_sdr.c +index fd2c02d..01d81f7 100644 +--- a/lib/ipmi_sdr.c ++++ b/lib/ipmi_sdr.c +@@ -2086,7 +2086,7 @@ ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf, + return -1; + + memset(desc, 0, sizeof (desc)); +- snprintf(desc, (sensor->id_code & 0x1f) + 1, "%s", sensor->id_string); ++ snprintf(desc, sizeof(desc), "%.*s", (sensor->id_code & 0x1f) + 1, sensor->id_string); + + if (verbose) { + printf("Sensor ID : %s (0x%x)\n", +@@ -2137,7 +2137,7 @@ ipmi_sdr_print_sensor_mc_locator(struct ipmi_intf *intf, + return -1; + + memset(desc, 0, sizeof (desc)); +- snprintf(desc, (mc->id_code & 0x1f) + 1, "%s", mc->id_string); ++ snprintf(desc, sizeof(desc), "%.*s", (mc->id_code & 0x1f) + 1, mc->id_string); + + if (verbose == 0) { + if (csv_output) +@@ -2230,7 +2230,7 @@ ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf, + char desc[17]; + + memset(desc, 0, sizeof (desc)); +- snprintf(desc, (dev->id_code & 0x1f) + 1, "%s", dev->id_string); ++ snprintf(desc, sizeof(desc), "%.*s", (dev->id_code & 0x1f) + 1, dev->id_string); + + if (!verbose) { + if (csv_output) +@@ -2287,7 +2287,7 @@ ipmi_sdr_print_sensor_fru_locator(struct ipmi_intf *intf, + char desc[17]; + + memset(desc, 0, sizeof (desc)); +- snprintf(desc, (fru->id_code & 0x1f) + 1, "%s", fru->id_string); ++ snprintf(desc, sizeof(desc), "%.*s", (fru->id_code & 0x1f) + 1, fru->id_string); + + if (!verbose) { + if (csv_output) +@@ -2491,35 +2491,43 @@ ipmi_sdr_print_name_from_rawentry(struct ipmi_intf *intf, uint16_t id, + + int rc =0; + char desc[17]; ++ const char *id_string; ++ uint8_t id_code; + memset(desc, ' ', sizeof (desc)); + + switch ( type) { + case SDR_RECORD_TYPE_FULL_SENSOR: + record.full = (struct sdr_record_full_sensor *) raw; +- snprintf(desc, (record.full->id_code & 0x1f) +1, "%s", +- (const char *)record.full->id_string); ++ id_code = record.full->id_code; ++ id_string = record.full->id_string; + break; ++ + case SDR_RECORD_TYPE_COMPACT_SENSOR: + record.compact = (struct sdr_record_compact_sensor *) raw ; +- snprintf(desc, (record.compact->id_code & 0x1f) +1, "%s", +- (const char *)record.compact->id_string); ++ id_code = record.compact->id_code; ++ id_string = record.compact->id_string; + break; ++ + case SDR_RECORD_TYPE_EVENTONLY_SENSOR: + record.eventonly = (struct sdr_record_eventonly_sensor *) raw ; +- snprintf(desc, (record.eventonly->id_code & 0x1f) +1, "%s", +- (const char *)record.eventonly->id_string); +- break; ++ id_code = record.eventonly->id_code; ++ id_string = record.eventonly->id_string; ++ break; ++ + case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR: + record.mcloc = (struct sdr_record_mc_locator *) raw ; +- snprintf(desc, (record.mcloc->id_code & 0x1f) +1, "%s", +- (const char *)record.mcloc->id_string); ++ id_code = record.mcloc->id_code; ++ id_string = record.mcloc->id_string; + break; ++ + default: + rc = -1; +- break; +- } ++ } ++ if (!rc) { ++ snprintf(desc, sizeof(desc), "%.*s", (id_code & 0x1f) + 1, id_string); ++ } + +- lprintf(LOG_INFO, "ID: 0x%04x , NAME: %-16s", id, desc); ++ lprintf(LOG_INFO, "ID: 0x%04x , NAME: %-16s", id, desc); + return rc; + } + +diff --git a/lib/ipmi_session.c b/lib/ipmi_session.c +index 141f0f4..b9af1fd 100644 +--- a/lib/ipmi_session.c ++++ b/lib/ipmi_session.c +@@ -309,8 +309,10 @@ ipmi_get_session_info(struct ipmi_intf * intf, + } + else + { +- memcpy(&session_info, rsp->data, rsp->data_len); +- print_session_info(&session_info, rsp->data_len); ++ memcpy(&session_info, rsp->data, ++ __min(rsp->data_len, sizeof(session_info))); ++ print_session_info(&session_info, ++ __min(rsp->data_len, sizeof(session_info))); + } + break; + +@@ -341,8 +343,10 @@ ipmi_get_session_info(struct ipmi_intf * intf, + break; + } + +- memcpy(&session_info, rsp->data, rsp->data_len); +- print_session_info(&session_info, rsp->data_len); ++ memcpy(&session_info, rsp->data, ++ __min(rsp->data_len, sizeof(session_info))); ++ print_session_info(&session_info, ++ __min(rsp->data_len, sizeof(session_info))); + + } while (i <= session_info.session_slot_count); + break; +-- +2.20.1 + diff --git a/SOURCES/0010-quanta-oem-support.patch b/SOURCES/0010-quanta-oem-support.patch new file mode 100644 index 0000000..d4b3809 --- /dev/null +++ b/SOURCES/0010-quanta-oem-support.patch @@ -0,0 +1,420 @@ +From 87a898756a7bd54898c1f6d2a5441efb1f810b67 Mon Sep 17 00:00:00 2001 +From: qctbmc +Date: Tue, 10 Jul 2018 11:21:55 +0800 +Subject: [PATCH] oem: Add basic support for Quanta + +--- + include/ipmitool/Makefile.am | 2 +- + include/ipmitool/ipmi_quantaoem.h | 55 +++++++++ + lib/Makefile.am | 2 +- + lib/ipmi_main.c | 1 + + lib/ipmi_oem.c | 14 +++ + lib/ipmi_quantaoem.c | 184 ++++++++++++++++++++++++++++++ + lib/ipmi_sel.c | 21 +++- + src/ipmitool.c | 1 + + 8 files changed, 274 insertions(+), 6 deletions(-) + create mode 100644 include/ipmitool/ipmi_quantaoem.h + create mode 100644 lib/ipmi_quantaoem.c + +diff --git a/include/ipmitool/Makefile.am b/include/ipmitool/Makefile.am +index 9093a56..8bc584a 100644 +--- a/include/ipmitool/Makefile.am ++++ b/include/ipmitool/Makefile.am +@@ -39,4 +39,4 @@ noinst_HEADERS = log.h bswap.h hpm2.h helper.h ipmi.h ipmi_cc.h ipmi_intf.h \ + ipmi_fwum.h ipmi_main.h ipmi_tsol.h ipmi_firewall.h \ + ipmi_kontronoem.h ipmi_ekanalyzer.h ipmi_gendev.h ipmi_ime.h \ + ipmi_delloem.h ipmi_dcmi.h ipmi_vita.h ipmi_sel_supermicro.h \ +- ipmi_cfgp.h ipmi_lanp6.h ++ ipmi_cfgp.h ipmi_lanp6.h ipmi_quantaoem.h +diff --git a/include/ipmitool/ipmi_quantaoem.h b/include/ipmitool/ipmi_quantaoem.h +new file mode 100644 +index 0000000..544f510 +--- /dev/null ++++ b/include/ipmitool/ipmi_quantaoem.h +@@ -0,0 +1,55 @@ ++/* ++ * Copyright (c) 2018 Quanta Computer Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * Redistribution of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * Redistribution in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * Neither the name of Quanta Computer Inc. or the names of ++ * contributors may be used to endorse or promote products derived ++ * from this software without specific prior written permission. ++ * ++ * This software is provided "AS IS," without a warranty of any kind. ++ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, ++ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A ++ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ++ * Quanta Computer Inc. AND ITS LICENSORS SHALL NOT BE LIABLE ++ * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING ++ * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ++ * Quanta Computer Inc. OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, ++ * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR ++ * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF ++ * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, ++ * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ++ */ ++ ++#ifndef IPMI_QUANTAOEM_H ++#define IPMI_QUANTAOEM_H ++ ++#if HAVE_CONFIG_H ++# include ++#endif ++#include ++#include ++ ++#define OEM_QCT_NETFN 0x36 ++#define OEM_QCT_GET_INFO 0x65 ++ ++typedef enum ++{ ++ OEM_QCT_PLATFORM_UNKNOWN = 0, ++ OEM_QCT_PLATFORM_GRANTLEY, ++ OEM_QCT_PLATFORM_PURLEY ++} qct_platform_t; ++ ++qct_platform_t oem_qct_get_platform_id(struct ipmi_intf *intf); ++char *oem_qct_get_evt_desc(struct ipmi_intf *intf, struct sel_event_record *rec); ++ ++#endif /*IPMI_QUANTAOEM_H*/ +diff --git a/lib/Makefile.am b/lib/Makefile.am +index cc69a8f..e7568f3 100644 +--- a/lib/Makefile.am ++++ b/lib/Makefile.am +@@ -41,7 +41,7 @@ libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_pef.c \ + ipmi_main.c ipmi_tsol.c ipmi_firewall.c ipmi_kontronoem.c \ + ipmi_hpmfwupg.c ipmi_sdradd.c ipmi_ekanalyzer.c ipmi_gendev.c \ + ipmi_ime.c ipmi_delloem.c ipmi_dcmi.c hpm2.c ipmi_vita.c \ +- ipmi_lanp6.c ipmi_cfgp.c \ ++ ipmi_lanp6.c ipmi_cfgp.c ipmi_quantaoem.c \ + ../src/plugins/lan/md5.c ../src/plugins/lan/md5.h + + libipmitool_la_LDFLAGS = -export-dynamic +diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c +index 6aee102..9d4a148 100644 +--- a/lib/ipmi_main.c ++++ b/lib/ipmi_main.c +@@ -75,6 +75,7 @@ + #include + #include + #include ++#include + + #ifdef HAVE_CONFIG_H + # include +diff --git a/lib/ipmi_oem.c b/lib/ipmi_oem.c +index 96db2ea..86fd803 100644 +--- a/lib/ipmi_oem.c ++++ b/lib/ipmi_oem.c +@@ -39,6 +39,7 @@ + + static int ipmi_oem_supermicro(struct ipmi_intf * intf); + static int ipmi_oem_ibm(struct ipmi_intf * intf); ++static int ipmi_oem_quanta(struct ipmi_intf * intf); + + static struct ipmi_oem_handle ipmi_oem_list[] = { + { +@@ -71,6 +72,11 @@ static struct ipmi_oem_handle ipmi_oem_list[] = { + .name = "kontron", + .desc = "Kontron OEM big buffer support" + }, ++ { ++ .name = "quanta", ++ .desc = "Quanta IPMIv1.5 BMC with OEM LAN authentication support", ++ .setup = ipmi_oem_quanta, ++ }, + { 0 } + }; + +@@ -93,6 +99,14 @@ ipmi_oem_ibm(struct ipmi_intf * intf) + return ipmi_sel_oem_init((const char *)filename); + } + ++/* Quanta IPMIv2 BMCs use OEM authtype */ ++static int ++ipmi_oem_quanta(struct ipmi_intf * intf) ++{ ++ ipmi_intf_session_set_authtype(intf, IPMI_SESSION_AUTHTYPE_OEM); ++ return 0; ++} ++ + /* ipmi_oem_print - print list of OEM handles + */ + void +diff --git a/lib/ipmi_quantaoem.c b/lib/ipmi_quantaoem.c +new file mode 100644 +index 0000000..7b4c5c6 +--- /dev/null ++++ b/lib/ipmi_quantaoem.c +@@ -0,0 +1,184 @@ ++/* ++ * Copyright (c) 2018 Quanta Computer Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * Redistribution of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * Redistribution in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * Neither the name of Quanta Computer Inc. or the names of ++ * contributors may be used to endorse or promote products derived ++ * from this software without specific prior written permission. ++ * ++ * This software is provided "AS IS," without a warranty of any kind. ++ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, ++ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A ++ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ++ * Quanta Computer Inc. AND ITS LICENSORS SHALL NOT BE LIABLE ++ * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING ++ * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ++ * Quanta Computer Inc. OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, ++ * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR ++ * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF ++ * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, ++ * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ++ */ ++#define _XOPEN_SOURCE ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Max Size of the description String to be displyed for the Each sel entry */ ++#define SIZE_OF_DESC 128 ++ ++#define CPU_SHIFT 6 ++#define CPU_MASK 0X03 ++#define CPU_NUM(x) (((x) >> CPU_SHIFT) & CPU_MASK) ++ ++#define CHANNEL_BASE 0x41 ++#define CHANNEL_SHIFT 3 ++#define CHANNEL_MASK 0x07 ++#define CHANNEL_OFFSET(x) (((x) >> CHANNEL_SHIFT) & CHANNEL_MASK) ++#define CHANNEL_NUM(x) (CHANNEL_BASE + CHANNEL_OFFSET(x)) ++ ++#define DIMM_MASK 0x07 ++#define DIMM_NUM(x) ((x) & DIMM_MASK) ++ ++#define GET_PLATFORM_ID_DATA_SIZE 4 ++ ++// Magic code to check if it's valid command ++#define QCT_MAGIC_1 0x4C ++#define QCT_MAGIC_2 0x1C ++#define QCT_MAGIC_3 0x00 ++#define QCT_MAGIC_4 0x02 ++ ++qct_platform_t ++oem_qct_get_platform_id(struct ipmi_intf *intf) ++{ ++ /* Execute a Get platform ID command to determine the board */ ++ struct ipmi_rs *rsp; ++ struct ipmi_rq req; ++ qct_platform_t platform_id; ++ uint8_t msg_data[GET_PLATFORM_ID_DATA_SIZE]; ++ ++ /* Ask for IPMI v2 data as well */ ++ msg_data[0] = QCT_MAGIC_1; ++ msg_data[1] = QCT_MAGIC_2; ++ msg_data[2] = QCT_MAGIC_3; ++ msg_data[3] = QCT_MAGIC_4; ++ ++ memset(&req, 0, sizeof(req)); ++ req.msg.netfn = OEM_QCT_NETFN; ++ req.msg.cmd = OEM_QCT_GET_INFO; ++ req.msg.data = msg_data; ++ req.msg.data_len = sizeof(msg_data); ++ ++ rsp = intf->sendrecv(intf, &req); ++ if (rsp == NULL) { ++ lprintf(LOG_ERR, "Get Platform ID command failed"); ++ return 0; ++ } ++ if (rsp->ccode) { ++ lprintf(LOG_ERR, "Get Platform ID command failed: %#x %s", ++ rsp->ccode, val2str(rsp->ccode, completion_code_vals)); ++ return 0; ++ } ++ platform_id = rsp->data[0]; ++ lprintf(LOG_DEBUG,"Platform ID: %hhx", rsp->data[0]); ++ return platform_id; ++} ++ ++char * ++oem_qct_get_evt_desc(struct ipmi_intf *intf, struct sel_event_record *rec) ++{ ++ struct ipmi_rs *rsp; ++ struct ipmi_rq req; ++ char *desc = NULL; ++ int data; ++ int sensor_type; ++ qct_platform_t platform_id; ++ ++ /* Get the OEM event Bytes of the SEL Records byte 15 to data */ ++ data = rec->sel_type.standard_type.event_data[2]; ++ /* Check for the Standard Event type == 0x6F */ ++ if (rec->sel_type.standard_type.event_type != 0x6F) { ++ goto out; ++ } ++ /* Allocate mem for te Description string */ ++ desc = malloc(SIZE_OF_DESC); ++ if (desc == NULL) { ++ lprintf(LOG_ERR, "ipmitool: malloc failure"); ++ goto out; ++ } ++ memset(desc, 0, SIZE_OF_DESC); ++ sensor_type = rec->sel_type.standard_type.sensor_type; ++ switch (sensor_type) { ++ case SENSOR_TYPE_MEMORY: ++ memset(&req, 0, sizeof (req)); ++ req.msg.netfn = IPMI_NETFN_APP; ++ req.msg.lun = 0; ++ req.msg.cmd = BMC_GET_DEVICE_ID; ++ req.msg.data = NULL; ++ req.msg.data_len = 0; ++ ++ rsp = intf->sendrecv(intf, &req); ++ if (rsp == NULL) { ++ lprintf(LOG_ERR, " Error getting system info"); ++ goto out; ++ } else if (rsp->ccode) { ++ lprintf(LOG_ERR, " Error getting system info: %s", ++ val2str(rsp->ccode, completion_code_vals)); ++ goto out; ++ } ++ /* check the platform type */ ++ platform_id = oem_qct_get_platform_id(intf); ++ if (OEM_QCT_PLATFORM_PURLEY == platform_id) { ++ snprintf(desc, SIZE_OF_DESC, "CPU%d_%c%d", ++ CPU_NUM(data), ++ CHANNEL_NUM(data), ++ DIMM_NUM(data)); ++ } ++ break; ++ default: ++ goto out; ++ } ++ return desc; ++out: ++ if (desc) { ++ free(desc); ++ desc = NULL; ++ } ++ return desc; ++} +diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c +index 8b0395e..a54fefd 100644 +--- a/lib/ipmi_sel.c ++++ b/lib/ipmi_sel.c +@@ -50,6 +50,7 @@ + #include + #include + #include ++#include + + extern int verbose; + static int sel_extended = 0; +@@ -1244,6 +1245,9 @@ ipmi_get_oem_desc(struct ipmi_intf * intf, struct sel_event_record * rec) + case IPMI_OEM_SUPERMICRO_47488: + desc = get_supermicro_evt_desc(intf, rec); + break; ++ case IPMI_OEM_QUANTA: ++ desc = oem_qct_get_evt_desc(intf, rec); ++ break; + case IPMI_OEM_UNKNOWN: + default: + break; +@@ -1349,6 +1353,9 @@ ipmi_get_event_desc(struct ipmi_intf * intf, struct sel_event_record * rec, char + sfx = ipmi_get_oem_desc(intf, rec); + break; + /* add your oem sensor assignation here */ ++ case IPMI_OEM_QUANTA: ++ sfx = ipmi_get_oem_desc(intf, rec); ++ break; + default: + lprintf(LOG_DEBUG, "oem sensor type %x using standard type supplied description", + rec->sel_type.standard_type.sensor_type ); +@@ -1359,9 +1366,12 @@ ipmi_get_event_desc(struct ipmi_intf * intf, struct sel_event_record * rec, char + case IPMI_OEM_SUPERMICRO: + case IPMI_OEM_SUPERMICRO_47488: + sfx = ipmi_get_oem_desc(intf, rec); +- break; ++ break; ++ case IPMI_OEM_QUANTA: ++ sfx = ipmi_get_oem_desc(intf, rec); ++ break; + default: +- break; ++ break; + } + } + /* +@@ -1986,9 +1996,12 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt) + case IPMI_OEM_SUPERMICRO: + case IPMI_OEM_SUPERMICRO_47488: + print_sensor = 0; +- break; ++ break; ++ case IPMI_OEM_QUANTA: ++ print_sensor = 0; ++ break; + default: +- break; ++ break; + } + /* + * Sensor-Specific Discrete +diff --git a/src/ipmitool.c b/src/ipmitool.c +index 5e19c6e..ec0b741 100644 +--- a/src/ipmitool.c ++++ b/src/ipmitool.c +@@ -66,6 +66,7 @@ + #include + #include + #include ++#include + + #ifdef HAVE_CONFIG_H + # include +-- +2.20.1 + diff --git a/SOURCES/0011-pef-missing-newline.patch b/SOURCES/0011-pef-missing-newline.patch new file mode 100644 index 0000000..9c52105 --- /dev/null +++ b/SOURCES/0011-pef-missing-newline.patch @@ -0,0 +1,33 @@ +From a365e624fff752bfe79438f6c177399492ccfdde Mon Sep 17 00:00:00 2001 +From: Vaclav Dolezal +Date: Fri, 1 Mar 2019 14:46:12 +0100 +Subject: [PATCH] Fix "ipmitool pef {status,info}" not printing final newline + +Signed-off-by: Vaclav Dolezal +--- + lib/ipmi_pef.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/ipmi_pef.c b/lib/ipmi_pef.c +index bbf25f2..4be749e 100644 +--- a/lib/ipmi_pef.c ++++ b/lib/ipmi_pef.c +@@ -1183,6 +1183,7 @@ ipmi_pef2_get_info(struct ipmi_intf *intf) + ipmi_pef_print_guid(guid_ptr); + } + ipmi_pef_print_flags(&pef_b2s_actions, P_SUPP, pcap.actions); ++ putchar('\n'); + return 0; + } + +@@ -1242,6 +1243,7 @@ ipmi_pef2_get_status(struct ipmi_intf *intf) + return (-1); + } + ipmi_pef_print_flags(&pef_b2s_actions, P_ACTV, rsp->data[1]); ++ putchar('\n'); + return 0; + } + +-- +2.25.4 + diff --git a/SOURCES/0012-lanplus-cipher-retry.patch b/SOURCES/0012-lanplus-cipher-retry.patch new file mode 100644 index 0000000..9aa3437 --- /dev/null +++ b/SOURCES/0012-lanplus-cipher-retry.patch @@ -0,0 +1,38 @@ +From 9d72def87ecc384d0a46525c766e755068fefe54 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=A1clav=20Dole=C5=BEal?= +Date: Thu, 28 May 2020 13:32:31 +0200 +Subject: [PATCH] lanplus: don't retry pre-session Get cipher suites +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some BMCs are ignoring it, causing needless delay. + +Signed-off-by: Václav Doležal +--- + src/plugins/lanplus/lanplus.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/plugins/lanplus/lanplus.c b/src/plugins/lanplus/lanplus.c +index 3087348..c442c0e 100644 +--- a/src/plugins/lanplus/lanplus.c ++++ b/src/plugins/lanplus/lanplus.c +@@ -3459,9 +3459,13 @@ ipmi_find_best_cipher_suite(struct ipmi_intf *intf) + }; + const size_t nr_preferred = ARRAY_SIZE(cipher_order_preferred); + size_t ipref, i; ++ int rc; ++ int retry_old = intf->ssn_params.retry; + +- if (ipmi_get_channel_cipher_suites(intf, "ipmi", IPMI_LAN_CHANNEL_E, +- suites, &nr_suites) < 0) ++ ipmi_intf_session_set_retry(intf, 1); ++ rc = ipmi_get_channel_cipher_suites(intf, "ipmi", IPMI_LAN_CHANNEL_E, suites, &nr_suites); ++ ipmi_intf_session_set_retry(intf, retry_old); ++ if (rc < 0) + { + /* default legacy behavior - cipher suite 3 if none is requested */ + return IPMI_LANPLUS_CIPHER_SUITE_3; +-- +2.25.4 + diff --git a/SPECS/ipmitool.spec b/SPECS/ipmitool.spec index 144460d..0befff9 100644 --- a/SPECS/ipmitool.spec +++ b/SPECS/ipmitool.spec @@ -1,7 +1,7 @@ Name: ipmitool Summary: Utility for IPMI control Version: 1.8.18 -Release: 12%{?dist} +Release: 17%{?dist} License: BSD URL: http://ipmitool.sourceforge.net/ Source0: http://downloads.sourceforge.net/project/%{name}/%{name}/%{version}/%{name}-%{version}.tar.bz2 @@ -21,6 +21,10 @@ Patch5: 0005-sensor-id-length.patch Patch6: 0006-enable-usb.patch Patch7: 0007-check-input.patch Patch8: 0008-use-best-cipher.patch +Patch9: 0009-CVE-2020-5208.patch +Patch10: 0010-quanta-oem-support.patch +Patch11: 0011-pef-missing-newline.patch +Patch12: 0012-lanplus-cipher-retry.patch BuildRequires: openssl-devel readline-devel ncurses-devel %{?systemd_requires} @@ -180,6 +184,22 @@ install -Dm 755 contrib/bmc-snmp-proxy %{buildroot}%{_libexecdir}/bmc-sn %{_libexecdir}/bmc-snmp-proxy %changelog +* Wed Jun 03 2020 Václav Doležal - 1.8.18-17 +- Disable retry of pre-session "Get cipher suites" command as some + BMCs are ignoring it (#1831158) + +* Thu Apr 30 2020 Václav Doležal - 1.8.18-16 +- Fix "ipmitool pef {status,info}" not printing final newline (#1840546) + +* Thu Apr 30 2020 Václav Doležal - 1.8.18-15 +- Backport OEM support for Quanta (#1811941) + +* Fri Feb 07 2020 Václav Doležal - 1.8.18-14 +- Fix memory leak (found by covscan) + +* Fri Feb 07 2020 Václav Doležal - 1.8.18-13 +- Backport fix for CVE-2020-5208 (#1799039) + * Fri Nov 15 2019 Václav Doležal - 1.8.18-12 - Disable -fstrict-aliasing (RPMDiff issue)