diff --git a/SOURCES/0020-plugins-open-Fix-for-interrupted-select.patch b/SOURCES/0020-plugins-open-Fix-for-interrupted-select.patch new file mode 100644 index 0000000..343f54e --- /dev/null +++ b/SOURCES/0020-plugins-open-Fix-for-interrupted-select.patch @@ -0,0 +1,33 @@ +From f222df3081d965051be76b85ea52b4aff222edf1 Mon Sep 17 00:00:00 2001 +From: "William A. Kennington III" +Date: Fri, 15 Jun 2018 14:47:12 -0700 +Subject: [PATCH] plugins/open: Fix for interrupted select + +The select syscall can be interrupted for signals like SIGPROF. The IPMI +command sent will still be outstanding but the send_command will return +an error. When the next command is sent it will get the completion for +the previous command and has the tendency to break state of end users. + +Signed-off-by: William A. Kennington III +--- + src/plugins/open/open.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/plugins/open/open.c b/src/plugins/open/open.c +index 5beeac7..59b736d 100644 +--- a/src/plugins/open/open.c ++++ b/src/plugins/open/open.c +@@ -335,7 +335,9 @@ ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req) + FD_SET(intf->fd, &rset); + read_timeout.tv_sec = IPMI_OPENIPMI_READ_TIMEOUT; + read_timeout.tv_usec = 0; +- retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout); ++ do { ++ retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout); ++ } while (retval < 0 && errno == EINTR); + if (retval < 0) { + lperror(LOG_ERR, "I/O Error"); + if (data != NULL) { +-- +2.40.1 + diff --git a/SOURCES/0021-open-checking-received-msg-id-against-expectation.patch b/SOURCES/0021-open-checking-received-msg-id-against-expectation.patch new file mode 100644 index 0000000..917756b --- /dev/null +++ b/SOURCES/0021-open-checking-received-msg-id-against-expectation.patch @@ -0,0 +1,98 @@ +diff -up ipmitool-1.8.18/src/plugins/open/open.c.checking-received ipmitool-1.8.18/src/plugins/open/open.c +--- ipmitool-1.8.18/src/plugins/open/open.c.checking-received 2023-07-25 17:14:22.112985375 +0200 ++++ ipmitool-1.8.18/src/plugins/open/open.c 2023-07-25 17:14:22.115985324 +0200 +@@ -336,48 +336,61 @@ ipmi_openipmi_send_cmd(struct ipmi_intf + read_timeout.tv_sec = IPMI_OPENIPMI_READ_TIMEOUT; + read_timeout.tv_usec = 0; + do { +- retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout); +- } while (retval < 0 && errno == EINTR); +- if (retval < 0) { +- lperror(LOG_ERR, "I/O Error"); +- if (data != NULL) { +- free(data); ++ do { ++ retval = select(intf->fd + 1, &rset, NULL, NULL, &read_timeout); ++ } while (retval < 0 && errno == EINTR); ++ if (retval < 0) { ++ lperror(LOG_ERR, "I/O Error"); ++ if (data != NULL) { ++ free(data); + data = NULL; +- } +- return NULL; +- } else if (retval == 0) { +- lprintf(LOG_ERR, "No data available"); +- if (data != NULL) { +- free(data); +- data = NULL; +- } +- return NULL; +- } +- if (FD_ISSET(intf->fd, &rset) == 0) { +- lprintf(LOG_ERR, "No data available"); +- if (data != NULL) { +- free(data); ++ } ++ return NULL; ++ } else if (retval == 0) { ++ lprintf(LOG_ERR, "No data available"); ++ if (data != NULL) { ++ free(data); + data = NULL; ++ } ++ return NULL; + } +- return NULL; +- } +- +- recv.addr = (unsigned char *) &addr; +- recv.addr_len = sizeof(addr); +- recv.msg.data = rsp.data; +- recv.msg.data_len = sizeof(rsp.data); +- +- /* get data */ +- if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) { +- lperror(LOG_ERR, "Error receiving message"); +- if (errno != EMSGSIZE) { ++ if (FD_ISSET(intf->fd, &rset) == 0) { ++ lprintf(LOG_ERR, "No data available"); + if (data != NULL) { + free(data); + data = NULL; + } + return NULL; + } +- } ++ ++ recv.addr = (unsigned char *)&addr; ++ recv.addr_len = sizeof(addr); ++ recv.msg.data = rsp.data; ++ recv.msg.data_len = sizeof(rsp.data); ++ ++ /* get data */ ++ if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) { ++ lperror(LOG_ERR, "Error receiving message"); ++ if (errno != EMSGSIZE) { ++ if (data != NULL) { ++ free(data); ++ data = NULL; ++ } ++ return NULL; ++ } ++ } ++ ++ /* If the message received wasn't expected, try to grab the ++ * next message until it's out of messages. -EAGAIN is ++ * returned if the list empty, but basically if it returns a ++ * message, check if it's alright. ++ */ ++ if (_req.msgid != recv.msgid) { ++ lprintf(LOG_NOTICE, ++ "Received a response with unexpected ID %ld vs. %ld", ++ recv.msgid, _req.msgid); ++ } ++ } while (_req.msgid != recv.msgid); + + if (verbose > 4) { + fprintf(stderr, "Got message:"); diff --git a/SPECS/ipmitool.spec b/SPECS/ipmitool.spec index e7ee740..81e903d 100644 --- a/SPECS/ipmitool.spec +++ b/SPECS/ipmitool.spec @@ -3,7 +3,7 @@ Name: ipmitool Summary: Utility for IPMI control Version: 1.8.18 -Release: 10%{?dist} +Release: 11%{?dist} License: BSD Group: System Environment/Base URL: http://ipmitool.sourceforge.net/ @@ -39,6 +39,8 @@ Patch16: 0016-ipmitool-1.8.18-verbose.patch Patch17: 0017-ipmitool-1.8.18-check-input-values.patch Patch18: 0018-CVE-2020-5208.patch Patch19: 0019-CVE-2020-5208_2.patch +Patch20: 0020-plugins-open-Fix-for-interrupted-select.patch +Patch21: 0021-open-checking-received-msg-id-against-expectation.patch %description @@ -101,6 +103,8 @@ for the host OS to use. %patch17 -p1 %patch18 -p1 %patch19 -p1 +%patch20 -p1 +%patch21 -p1 for f in AUTHORS ChangeLog; do iconv -f iso-8859-1 -t utf8 < ${f} > ${f}.utf8 @@ -194,6 +198,12 @@ install -Dm 755 contrib/bmc-snmp-proxy %{buildroot}%{_libexecdir}/bmc-sn %{_libexecdir}/bmc-snmp-proxy %changelog +* Wed Aug 9 2023 Pavel Cahyna - 1.8.18-11 +- Add upstream ipmievd patch to check received msg id against expectation + Fixes problem where SEL response is not recognized correctly + when SEL request times out + Resolves: rhbz#2224569 + * Fri Dec 17 2021 Pavel Cahyna - 0:1.8.18-10 - Protect against negative values to memmove that caused "ipmitool sol activate" to crash against an IBM DataPower appliance