diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces')
4 files changed, 327 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0039-Return-InternalError-on-DBus-error.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0039-Return-InternalError-on-DBus-error.patch new file mode 100644 index 000000000..f36ff76c8 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0039-Return-InternalError-on-DBus-error.patch @@ -0,0 +1,41 @@ +From 1a78cc35251621eec99f092fb39c8bb303681395 Mon Sep 17 00:00:00 2001 +From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> +Date: Thu, 21 Jan 2021 14:41:15 +0100 +Subject: [PATCH] Return InternalError on DBus error + +Fixes returning empty response with 200 return code on GET request on +Virtual Media resource. +This happens when eg. dbus is highly occupied. Dbus call return timeout +error and response is silently dropped. +This update makes the response for such request more verbose, making +user aware that something went wrong. + +Tested: +Tested using Multiple_simultaneous_sessions.py. The one used to +reproduce this problem. + +Change-Id: I2c72684a2f4379ef32432895bdf0f412880790f2 +Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> +--- + redfish-core/lib/virtual_media.hpp | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp +index 5739204..70368eb 100644 +--- a/redfish-core/lib/virtual_media.hpp ++++ b/redfish-core/lib/virtual_media.hpp +@@ -223,7 +223,10 @@ static void getVmData(std::shared_ptr<AsyncResp> aResp, + ManagedObjectType& subtree) { + if (ec) + { +- BMCWEB_LOG_DEBUG << "DBUS response error"; ++ BMCWEB_LOG_ERROR ++ << "VirtualMedia::GetManagedObjects() D-Bus call error: " ++ << ec; ++ messages::internalError(aResp->res); + + return; + } +-- +2.26.2 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0040-Add-boundary-check-to-avoid-crash.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0040-Add-boundary-check-to-avoid-crash.patch new file mode 100644 index 000000000..ecb40c5b1 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0040-Add-boundary-check-to-avoid-crash.patch @@ -0,0 +1,58 @@ +From 87542156191bbfbc4f40a62ca4d8e67dc4f7d173 Mon Sep 17 00:00:00 2001 +From: AppaRao Puli <apparao.puli@linux.intel.com> +Date: Fri, 22 Jan 2021 13:31:20 +0530 +Subject: [PATCH] Add boundary check to avoid crash + +While stressing the firmware updates, its found +that bmcweb is crashing with below error. +Jan 06 21:38:40 intel-obmc bmcweb[388]: malloc(): unsorted double linked list corrupted +Jan 06 21:38:42 intel-obmc systemd[1]: bmcweb.service: Main process exited, code=dumped, status=6/ABRT +Jan 06 21:38:42 intel-obmc systemd[1]: bmcweb.service: Failed with result 'core-dump'. + +Further reviewing code, Its found that this could +be due to memory usage out of boundary. So change strcpy +to safe strncpy call. Also added return value check for +calloc failure. + +Tested: + - Performed some redfish stress with basic auth. + - Performed firmware updates stressing and no issues + found afterwards. + +Change-Id: I43767ec294c0de08047f4108adbda950bf84007a +Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com> +--- + include/pam_authenticate.hpp | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp +index 912093a..12f19c0 100644 +--- a/include/pam_authenticate.hpp ++++ b/include/pam_authenticate.hpp +@@ -23,17 +23,18 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg, + return PAM_AUTH_ERR; + } + +- std::strcpy(pass, appPass); ++ std::strncpy(pass, appPass, appPassSize + 1); + +- *resp = reinterpret_cast<pam_response*>( +- calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response))); +- +- if (resp == nullptr) ++ void* ptr = ++ calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response)); ++ if (ptr == nullptr) + { + free(pass); + return PAM_AUTH_ERR; + } + ++ *resp = reinterpret_cast<pam_response*>(ptr); ++ + for (int i = 0; i < numMsg; ++i) + { + /* Ignore all PAM messages except prompting for hidden input */ +-- +2.7.4 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0041-Revamp-Redfish-Event-Log-Unique-ID-Generation.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0041-Revamp-Redfish-Event-Log-Unique-ID-Generation.patch new file mode 100644 index 000000000..8e61673e3 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0041-Revamp-Redfish-Event-Log-Unique-ID-Generation.patch @@ -0,0 +1,225 @@ +From 1c557e1d8bee8f66d97037b0dc8ae392c6ec45d3 Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com> +Date: Fri, 22 Jan 2021 17:00:21 +0530 +Subject: [PATCH] Revamp Redfish Event Log Unique ID Generation + +The unique ID for Redfish log events was generated using +the Timestamp of the log until seconds. This commit +allows the use of microseconds as well to create unique +Redfish Log ID, thereby improving the uniqueness of each +Log event ID + +Tested: +- GET of /redfish/v1/Systems/system/LogServices/EventLog/Entries + produces unique LogEvent Id's +- Verified Event ID's on Event listener. +- Redfish validator passed + +Change-Id: Ie2046a8ee7f9e7f6f14b05071b18a291c4313370 +Signed-off-by: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com> +--- + .../include/event_service_manager.hpp | 40 +++++------- + redfish-core/lib/log_services.hpp | 63 ++++++------------- + 2 files changed, 35 insertions(+), 68 deletions(-) + +diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp +index afbf799..470636f 100644 +--- a/redfish-core/include/event_service_manager.hpp ++++ b/redfish-core/include/event_service_manager.hpp +@@ -142,38 +142,32 @@ static const Message* formatMessage(const std::string_view& messageID) + + namespace event_log + { +-bool getUniqueEntryID(const std::string& logEntry, std::string& entryID, +- const bool firstEntry = true) ++bool getUniqueEntryID(const std::string& logEntry, std::string& entryID) + { +- static time_t prevTs = 0; +- static int index = 0; +- if (firstEntry) +- { +- prevTs = 0; +- } +- + // Get the entry timestamp +- std::time_t curTs = 0; + std::tm timeStruct = {}; + std::istringstream entryStream(logEntry); + if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S")) + { +- curTs = std::mktime(&timeStruct); +- if (curTs == -1) ++ time_t seconds = std::mktime(&timeStruct); ++ if (seconds == -1) + { + return false; + } +- } +- // If the timestamp isn't unique, increment the index +- index = (curTs == prevTs) ? index + 1 : 0; +- +- // Save the timestamp +- prevTs = curTs; + +- entryID = std::to_string(curTs); +- if (index > 0) ++ size_t dot = logEntry.find_first_of("."); ++ if (dot == std::string::npos) ++ { ++ return false; ++ } ++ // 2015-10-24T06:54:38.383093 => 6 digits for microseconds ++ std::string microSec = logEntry.substr((dot + 1), 6); ++ entryID = std::to_string(seconds) + "_"; ++ entryID += microSec; ++ } ++ else + { +- entryID += "_" + std::to_string(index); ++ return false; + } + return true; + } +@@ -1131,7 +1125,6 @@ class EventServiceManager + std::vector<EventLogObjectsType> eventRecords; + + bool startLogCollection = false; +- bool firstEntry = true; + + std::string logEntry; + while (std::getline(logStream, logEntry)) +@@ -1146,11 +1139,10 @@ class EventServiceManager + } + + std::string idStr; +- if (!event_log::getUniqueEntryID(logEntry, idStr, firstEntry)) ++ if (!event_log::getUniqueEntryID(logEntry, idStr)) + { + continue; + } +- firstEntry = false; + + std::string timestamp; + std::string messageID; +diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp +index e6a9022..ee064ce 100644 +--- a/redfish-core/lib/log_services.hpp ++++ b/redfish-core/lib/log_services.hpp +@@ -306,41 +306,32 @@ static bool getUniqueEntryID(sd_journal* journal, std::string& entryID, + return true; + } + +-static bool getUniqueEntryID(const std::string& logEntry, std::string& entryID, +- const bool firstEntry = true) ++static bool getUniqueEntryID(const std::string& logEntry, std::string& entryID) + { +- static time_t prevTs = 0; +- static int index = 0; +- if (firstEntry) +- { +- prevTs = 0; +- } +- + // Get the entry timestamp +- std::time_t curTs = 0; + std::tm timeStruct = {}; + std::istringstream entryStream(logEntry); + if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S")) + { +- curTs = std::mktime(&timeStruct); +- } +- // If the timestamp isn't unique, increment the index +- if (curTs == prevTs) +- { +- index++; ++ time_t seconds = std::mktime(&timeStruct); ++ if (seconds == -1) ++ { ++ return false; ++ } ++ ++ size_t dot = logEntry.find_first_of("."); ++ if (dot == std::string::npos) ++ { ++ return false; ++ } ++ // 2015-10-24T06:54:38.383093 => 6 digits for microseconds ++ std::string microSec = logEntry.substr((dot + 1), 6); ++ entryID = std::to_string(seconds) + "_"; ++ entryID += microSec; + } + else + { +- // Otherwise, reset it +- index = 0; +- } +- // Save the timestamp +- prevTs = curTs; +- +- entryID = std::to_string(curTs); +- if (index > 0) +- { +- entryID += "_" + std::to_string(index); ++ return false; + } + return true; + } +@@ -1265,9 +1256,6 @@ class JournalEventLogEntryCollection : public Node + uint64_t entryCount = 0; + std::string logEntry; + +- // Reset the unique ID on the first entry +- bool firstEntry = true; +- + // Oldest logs are in the last file, so start there and loop backwards + for (auto it = redfishLogFiles.rbegin(); it < redfishLogFiles.rend(); + it++) +@@ -1289,16 +1277,11 @@ class JournalEventLogEntryCollection : public Node + } + + std::string idStr; +- if (!getUniqueEntryID(logEntry, idStr, firstEntry)) ++ if (!getUniqueEntryID(logEntry, idStr)) + { + continue; + } + +- if (firstEntry) +- { +- firstEntry = false; +- } +- + logEntryArray.push_back({}); + nlohmann::json& bmcLogEntry = logEntryArray.back(); + if (fillEventLogEntryJson(idStr, logEntry, bmcLogEntry) != 0) +@@ -1354,9 +1337,6 @@ class JournalEventLogEntry : public Node + getRedfishLogFiles(redfishLogFiles); + std::string logEntry; + +- // Reset the unique ID on the first entry +- bool firstEntry = true; +- + // Oldest logs are in the last file, so start there and loop backwards + for (auto it = redfishLogFiles.rbegin(); it < redfishLogFiles.rend(); + it++) +@@ -1370,16 +1350,11 @@ class JournalEventLogEntry : public Node + while (std::getline(logStream, logEntry)) + { + std::string idStr; +- if (!getUniqueEntryID(logEntry, idStr, firstEntry)) ++ if (!getUniqueEntryID(logEntry, idStr)) + { + continue; + } + +- if (firstEntry) +- { +- firstEntry = false; +- } +- + if (idStr == targetID) + { + if (fillEventLogEntryJson(idStr, logEntry, +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend index 279b8bec4..b409243a4 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend @@ -53,6 +53,9 @@ SRC_URI += "file://0001-Firmware-update-support-for-StandBySpare.patch \ file://0036-fix-bmcweb-crash-during-sol-communication.patch \ file://0037-Use-non-throw-version-of-remote_endpoint.patch \ file://0038-Change-Severity-for-ServiceFailure-redfish-event.patch \ + file://0039-Return-InternalError-on-DBus-error.patch \ + file://0040-Add-boundary-check-to-avoid-crash.patch \ + file://0041-Revamp-Redfish-Event-Log-Unique-ID-Generation.patch \ " # Temporary downstream mirror of upstream patches, see telemetry\README for details |