aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-kernel/ipmitool/ipmitool/0005-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch')
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0005-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch94
1 files changed, 94 insertions, 0 deletions
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
new file mode 100644
index 0000000000..1b1dec1c1b
--- /dev/null
+++ b/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
@@ -0,0 +1,94 @@
+From f45e6d84b75dcd649e18c9256c136cda354de6fd Mon Sep 17 00:00:00 2001
+From: Chrostoper Ertl <chertl@microsoft.com>
+Date: Thu, 28 Nov 2019 17:06:39 +0000
+Subject: [PATCH 5/6] lanp: Fix buffer overflows in get_lan_param_select
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Partial fix for CVE-2020-5208, see
+https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
+
+The `get_lan_param_select` function is missing a validation check on the
+response’s `data_len`, which it then returns to caller functions, where
+stack buffer overflow can occur.
+
+Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/d45572d71e70840e0d4c50bf48218492b79c1a10]
+CVE: CVE-2020-5208
+
+[Make some changes to apply it]
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+---
+ lib/ipmi_lanp.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+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]);
+--
+2.23.0
+