summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0001-Migrate-to-openssl-1.1.patch152
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0001-configure-Remove-the-logic-to-download-IANA-PEN-data.patch41
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch53
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-vulnerabilities.patch133
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0001-hpmfwupg-move-variable-definition-to-.c-file.patch41
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0001-ipmi_fru.c-Provide-missing-function-declarations.patch34
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0002-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch53
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0003-channel-Fix-buffer-overflow.patch69
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0004-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch94
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool/0005-fru-sdr-Fix-id_string-buffer-overflows.patch142
-rw-r--r--meta-oe/recipes-kernel/ipmitool/ipmitool_1.8.19.bb (renamed from meta-oe/recipes-kernel/ipmitool/ipmitool_1.8.18.bb)31
11 files changed, 94 insertions, 749 deletions
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-Migrate-to-openssl-1.1.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-Migrate-to-openssl-1.1.patch
deleted file mode 100644
index 394aa16adc..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-Migrate-to-openssl-1.1.patch
+++ /dev/null
@@ -1,152 +0,0 @@
1From c9dcb6afef9c343d070aaff208d11a997a45a105 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 5 Sep 2018 22:19:38 -0700
4Subject: [PATCH] Migrate to openssl 1.1
5
6Upstream-Status: Backport [https://sourceforge.net/p/ipmitool/source/ci/1664902525a1c3771b4d8b3ccab7ea1ba6b2bdd1/]
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 src/plugins/lanplus/lanplus_crypt_impl.c | 50 ++++++++++++++----------
11 1 file changed, 29 insertions(+), 21 deletions(-)
12
13diff --git a/src/plugins/lanplus/lanplus_crypt_impl.c b/src/plugins/lanplus/lanplus_crypt_impl.c
14index d5fac37..9652a5e 100644
15--- a/src/plugins/lanplus/lanplus_crypt_impl.c
16+++ b/src/plugins/lanplus/lanplus_crypt_impl.c
17@@ -164,11 +164,7 @@ lanplus_encrypt_aes_cbc_128(const uint8_t * iv,
18 uint8_t * output,
19 uint32_t * bytes_written)
20 {
21- EVP_CIPHER_CTX ctx;
22- EVP_CIPHER_CTX_init(&ctx);
23- EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv);
24- EVP_CIPHER_CTX_set_padding(&ctx, 0);
25-
26+ EVP_CIPHER_CTX *ctx = NULL;
27
28 *bytes_written = 0;
29
30@@ -182,6 +178,14 @@ lanplus_encrypt_aes_cbc_128(const uint8_t * iv,
31 printbuf(input, input_length, "encrypting this data");
32 }
33
34+ ctx = EVP_CIPHER_CTX_new();
35+ if (ctx == NULL) {
36+ lprintf(LOG_DEBUG, "ERROR: EVP_CIPHER_CTX_new() failed");
37+ return;
38+ }
39+ EVP_CIPHER_CTX_init(ctx);
40+ EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
41+ EVP_CIPHER_CTX_set_padding(ctx, 0);
42
43 /*
44 * The default implementation adds a whole block of padding if the input
45@@ -191,28 +195,28 @@ lanplus_encrypt_aes_cbc_128(const uint8_t * iv,
46 assert((input_length % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE) == 0);
47
48
49- if(!EVP_EncryptUpdate(&ctx, output, (int *)bytes_written, input, input_length))
50+ if(!EVP_EncryptUpdate(ctx, output, (int *)bytes_written, input, input_length))
51 {
52 /* Error */
53 *bytes_written = 0;
54- return;
55 }
56 else
57 {
58 uint32_t tmplen;
59
60- if(!EVP_EncryptFinal_ex(&ctx, output + *bytes_written, (int *)&tmplen))
61+ if(!EVP_EncryptFinal_ex(ctx, output + *bytes_written, (int *)&tmplen))
62 {
63+ /* Error */
64 *bytes_written = 0;
65- return; /* Error */
66 }
67 else
68 {
69 /* Success */
70 *bytes_written += tmplen;
71- EVP_CIPHER_CTX_cleanup(&ctx);
72 }
73 }
74+ /* performs cleanup and free */
75+ EVP_CIPHER_CTX_free(ctx);
76 }
77
78
79@@ -239,11 +243,7 @@ lanplus_decrypt_aes_cbc_128(const uint8_t * iv,
80 uint8_t * output,
81 uint32_t * bytes_written)
82 {
83- EVP_CIPHER_CTX ctx;
84- EVP_CIPHER_CTX_init(&ctx);
85- EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv);
86- EVP_CIPHER_CTX_set_padding(&ctx, 0);
87-
88+ EVP_CIPHER_CTX *ctx = NULL;
89
90 if (verbose >= 5)
91 {
92@@ -252,12 +252,20 @@ lanplus_decrypt_aes_cbc_128(const uint8_t * iv,
93 printbuf(input, input_length, "decrypting this data");
94 }
95
96-
97 *bytes_written = 0;
98
99 if (input_length == 0)
100 return;
101
102+ ctx = EVP_CIPHER_CTX_new();
103+ if (ctx == NULL) {
104+ lprintf(LOG_DEBUG, "ERROR: EVP_CIPHER_CTX_new() failed");
105+ return;
106+ }
107+ EVP_CIPHER_CTX_init(ctx);
108+ EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
109+ EVP_CIPHER_CTX_set_padding(ctx, 0);
110+
111 /*
112 * The default implementation adds a whole block of padding if the input
113 * data is perfectly aligned. We would like to keep that from happening.
114@@ -266,33 +274,33 @@ lanplus_decrypt_aes_cbc_128(const uint8_t * iv,
115 assert((input_length % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE) == 0);
116
117
118- if (!EVP_DecryptUpdate(&ctx, output, (int *)bytes_written, input, input_length))
119+ if (!EVP_DecryptUpdate(ctx, output, (int *)bytes_written, input, input_length))
120 {
121 /* Error */
122 lprintf(LOG_DEBUG, "ERROR: decrypt update failed");
123 *bytes_written = 0;
124- return;
125 }
126 else
127 {
128 uint32_t tmplen;
129
130- if (!EVP_DecryptFinal_ex(&ctx, output + *bytes_written, (int *)&tmplen))
131+ if (!EVP_DecryptFinal_ex(ctx, output + *bytes_written, (int *)&tmplen))
132 {
133+ /* Error */
134 char buffer[1000];
135 ERR_error_string(ERR_get_error(), buffer);
136 lprintf(LOG_DEBUG, "the ERR error %s", buffer);
137 lprintf(LOG_DEBUG, "ERROR: decrypt final failed");
138 *bytes_written = 0;
139- return; /* Error */
140 }
141 else
142 {
143 /* Success */
144 *bytes_written += tmplen;
145- EVP_CIPHER_CTX_cleanup(&ctx);
146 }
147 }
148+ /* performs cleanup and free */
149+ EVP_CIPHER_CTX_free(ctx);
150
151 if (verbose >= 5)
152 {
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-configure-Remove-the-logic-to-download-IANA-PEN-data.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-configure-Remove-the-logic-to-download-IANA-PEN-data.patch
new file mode 100644
index 0000000000..442f132718
--- /dev/null
+++ b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-configure-Remove-the-logic-to-download-IANA-PEN-data.patch
@@ -0,0 +1,41 @@
1From 63d72f97bd106dd2101cd7fdac6df4f7a053d67c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 2 Sep 2022 08:27:39 -0700
4Subject: [PATCH] configure: Remove the logic to download IANA PEN database
5 during configure
6
7OE will do all downloading before it starts to configure therefore this
8step is moved out into bitbake recipe, so we can make it immutable build
9
10Upstream-Status: Inappropriate [OE-Specific]
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 configure.ac | 16 +---------------
15 1 file changed, 1 insertion(+), 15 deletions(-)
16
17--- a/configure.ac
18+++ b/configure.ac
19@@ -56,21 +56,7 @@ if test "x$exec_prefix" = "xNONE"; then
20 exec_prefix="$prefix"
21 fi
22
23-if test "x$WGET" = "x"; then
24- if test "x$CURL" = "x"; then
25- AC_MSG_WARN([** Neither wget nor curl could be found.])
26- AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !])
27- else
28- DOWNLOAD="$CURL --location --progress-bar"
29- AM_CONDITIONAL([DOWNLOAD], [true])
30- fi
31-else
32- DOWNLOAD="$WGET -c -nd -O -"
33- AM_CONDITIONAL([DOWNLOAD], [true])
34-fi
35-
36-AC_MSG_WARN([** Download is:])
37-AC_MSG_WARN($DOWNLOAD)
38+AM_CONDITIONAL([DOWNLOAD], [false])
39 AC_SUBST(DOWNLOAD, $DOWNLOAD)
40
41 dnl
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch
deleted file mode 100644
index eadfb7ead3..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch
+++ /dev/null
@@ -1,53 +0,0 @@
1From 24aed93efb30a8f557aedc2f03b6ccec758ccbf4 Mon Sep 17 00:00:00 2001
2From: Chrostoper Ertl <chertl@microsoft.com>
3Date: Thu, 28 Nov 2019 16:44:18 +0000
4Subject: [PATCH 1/5] fru: Fix buffer overflow in ipmi_spd_print_fru
5
6Partial fix for CVE-2020-5208, see
7https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
8
9The `ipmi_spd_print_fru` function has a similar issue as the one fixed
10by the previous commit in `read_fru_area_section`. An initial request is
11made to get the `fru.size`, which is used as the size for the allocation
12of `spd_data`. Inside a loop, further requests are performed to get the
13copy sizes which are not checked before being used as the size for a
14copy into the buffer.
15
16Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/840fb1cbb4fb365cb9797300e3374d4faefcdb10]
17CVE: CVE-2020-5208
18
19Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
20---
21 lib/dimm_spd.c | 9 ++++++++-
22 1 file changed, 8 insertions(+), 1 deletion(-)
23
24diff --git a/lib/dimm_spd.c b/lib/dimm_spd.c
25index 91ae117..4c9c21d 100644
26--- a/lib/dimm_spd.c
27+++ b/lib/dimm_spd.c
28@@ -1014,7 +1014,7 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
29 struct ipmi_rq req;
30 struct fru_info fru;
31 uint8_t *spd_data, msg_data[4];
32- int len, offset;
33+ uint32_t len, offset;
34
35 msg_data[0] = id;
36
37@@ -1091,6 +1091,13 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
38 }
39
40 len = rsp->data[0];
41+ if(rsp->data_len < 1
42+ || len > rsp->data_len - 1
43+ || len > fru.size - offset)
44+ {
45+ printf(" Not enough buffer size");
46+ return -1;
47+ }
48 memcpy(&spd_data[offset], rsp->data + 1, len);
49 offset += len;
50 } while (offset < fru.size);
51--
521.9.1
53
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-vulnerabilities.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-vulnerabilities.patch
deleted file mode 100644
index b65e3ef1a6..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-fru-Fix-buffer-overflow-vulnerabilities.patch
+++ /dev/null
@@ -1,133 +0,0 @@
1From e824c23316ae50beb7f7488f2055ac65e8b341f2 Mon Sep 17 00:00:00 2001
2From: Chrostoper Ertl <chertl@microsoft.com>
3Date: Thu, 28 Nov 2019 16:33:59 +0000
4Subject: [PATCH] fru: Fix buffer overflow vulnerabilities
5
6Partial fix for CVE-2020-5208, see
7https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
8
9The `read_fru_area_section` function only performs size validation of
10requested read size, and falsely assumes that the IPMI message will not
11respond with more than the requested amount of data; it uses the
12unvalidated response size to copy into `frubuf`. If the response is
13larger than the request, this can result in overflowing the buffer.
14
15The same issue affects the `read_fru_area` function.
16
17Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/e824c23316ae50beb7f7488f2055ac65e8b341f2]
18CVE: CVE-2020-5208
19
20Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
21---
22 lib/ipmi_fru.c | 33 +++++++++++++++++++++++++++++++--
23 1 file changed, 31 insertions(+), 2 deletions(-)
24
25diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
26index c2a139d..2e323ff 100644
27--- a/lib/ipmi_fru.c
28+++ b/lib/ipmi_fru.c
29@@ -663,7 +663,10 @@ int
30 read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
31 uint32_t offset, uint32_t length, uint8_t *frubuf)
32 {
33- uint32_t off = offset, tmp, finish;
34+ uint32_t off = offset;
35+ uint32_t tmp;
36+ uint32_t finish;
37+ uint32_t size_left_in_buffer;
38 struct ipmi_rs * rsp;
39 struct ipmi_rq req;
40 uint8_t msg_data[4];
41@@ -676,10 +679,12 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
42
43 finish = offset + length;
44 if (finish > fru->size) {
45+ memset(frubuf + fru->size, 0, length - fru->size);
46 finish = fru->size;
47 lprintf(LOG_NOTICE, "Read FRU Area length %d too large, "
48 "Adjusting to %d",
49 offset + length, finish - offset);
50+ length = finish - offset;
51 }
52
53 memset(&req, 0, sizeof(req));
54@@ -715,6 +720,7 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
55 }
56 }
57
58+ size_left_in_buffer = length;
59 do {
60 tmp = fru->access ? off >> 1 : off;
61 msg_data[0] = id;
62@@ -756,9 +762,18 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
63 }
64
65 tmp = fru->access ? rsp->data[0] << 1 : rsp->data[0];
66+ if(rsp->data_len < 1
67+ || tmp > rsp->data_len - 1
68+ || tmp > size_left_in_buffer)
69+ {
70+ printf(" Not enough buffer size");
71+ return -1;
72+ }
73+
74 memcpy(frubuf, rsp->data + 1, tmp);
75 off += tmp;
76 frubuf += tmp;
77+ size_left_in_buffer -= tmp;
78 /* sometimes the size returned in the Info command
79 * is too large. return 0 so higher level function
80 * still attempts to parse what was returned */
81@@ -791,7 +806,9 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
82 uint32_t offset, uint32_t length, uint8_t *frubuf)
83 {
84 static uint32_t fru_data_rqst_size = 20;
85- uint32_t off = offset, tmp, finish;
86+ uint32_t off = offset;
87+ uint32_t tmp, finish;
88+ uint32_t size_left_in_buffer;
89 struct ipmi_rs * rsp;
90 struct ipmi_rq req;
91 uint8_t msg_data[4];
92@@ -804,10 +821,12 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
93
94 finish = offset + length;
95 if (finish > fru->size) {
96+ memset(frubuf + fru->size, 0, length - fru->size);
97 finish = fru->size;
98 lprintf(LOG_NOTICE, "Read FRU Area length %d too large, "
99 "Adjusting to %d",
100 offset + length, finish - offset);
101+ length = finish - offset;
102 }
103
104 memset(&req, 0, sizeof(req));
105@@ -822,6 +841,8 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
106 if (fru->access && fru_data_rqst_size > 16)
107 #endif
108 fru_data_rqst_size = 16;
109+
110+ size_left_in_buffer = length;
111 do {
112 tmp = fru->access ? off >> 1 : off;
113 msg_data[0] = id;
114@@ -853,8 +874,16 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
115 }
116
117 tmp = fru->access ? rsp->data[0] << 1 : rsp->data[0];
118+ if(rsp->data_len < 1
119+ || tmp > rsp->data_len - 1
120+ || tmp > size_left_in_buffer)
121+ {
122+ printf(" Not enough buffer size");
123+ return -1;
124+ }
125 memcpy((frubuf + off)-offset, rsp->data + 1, tmp);
126 off += tmp;
127+ size_left_in_buffer -= tmp;
128
129 /* sometimes the size returned in the Info command
130 * is too large. return 0 so higher level function
131--
1322.17.1
133
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-hpmfwupg-move-variable-definition-to-.c-file.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-hpmfwupg-move-variable-definition-to-.c-file.patch
deleted file mode 100644
index a765c3ab2f..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-hpmfwupg-move-variable-definition-to-.c-file.patch
+++ /dev/null
@@ -1,41 +0,0 @@
1From 3f7bb7218181745ca7762c1b4832cbb1c9e692f5 Mon Sep 17 00:00:00 2001
2From: Vaclav Dolezal <vdolezal@redhat.com>
3Date: Thu, 23 Jan 2020 11:26:32 +0100
4Subject: [PATCH] hpmfwupg: move variable definition to .c file
5
6Upstream-Status: Pending
7Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
8---
9 include/ipmitool/ipmi_hpmfwupg.h | 2 +-
10 lib/ipmi_hpmfwupg.c | 2 ++
11 2 files changed, 3 insertions(+), 1 deletion(-)
12
13diff --git a/include/ipmitool/ipmi_hpmfwupg.h b/include/ipmitool/ipmi_hpmfwupg.h
14index de65292..07f597b 100644
15--- a/include/ipmitool/ipmi_hpmfwupg.h
16+++ b/include/ipmitool/ipmi_hpmfwupg.h
17@@ -800,7 +800,7 @@ typedef struct _VERSIONINFO {
18 char descString[HPMFWUPG_DESC_STRING_LENGTH + 1];
19 }VERSIONINFO, *PVERSIONINFO;
20
21-VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
22+extern VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
23
24 #define TARGET_VER (0x01)
25 #define ROLLBACK_VER (0x02)
26diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c
27index bbcffc0..d7cdcd6 100644
28--- a/lib/ipmi_hpmfwupg.c
29+++ b/lib/ipmi_hpmfwupg.c
30@@ -58,6 +58,8 @@ ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf);
31
32 extern int verbose;
33
34+VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
35+
36 int HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename,
37 int activate, int, int);
38 int HpmfwupgValidateImageIntegrity(struct HpmfwupgUpgradeCtx *pFwupgCtx);
39--
402.28.0
41
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-ipmi_fru.c-Provide-missing-function-declarations.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-ipmi_fru.c-Provide-missing-function-declarations.patch
new file mode 100644
index 0000000000..704bbdb5c7
--- /dev/null
+++ b/meta-oe/recipes-kernel/ipmitool/ipmitool/0001-ipmi_fru.c-Provide-missing-function-declarations.patch
@@ -0,0 +1,34 @@
1From e5bbf96edf776821f29ab67baed22a690bf8ab10 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 2 Sep 2022 07:30:10 -0700
4Subject: [PATCH] ipmi_fru.c: Provide missing function declarations
5
6Fixes build with clang-15+
7
8Upstream-Status: Submitted [https://github.com/ipmitool/ipmitool/pull/360]
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 lib/ipmi_fru.c | 7 +++++++
12 1 file changed, 7 insertions(+)
13
14diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
15index 3d1d8a1..5c5661c 100644
16--- a/lib/ipmi_fru.c
17+++ b/lib/ipmi_fru.c
18@@ -60,6 +60,13 @@ static const char *section_id[4] = {
19 "Board Section",
20 "Product Section"
21 };
22+/* From lib/ipmi_hpmfwupg.c: */
23+uint16_t
24+ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf);
25+
26+/* From src/plugins/ipmi_intf.c: */
27+uint16_t
28+ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf);
29
30 static const char * combined_voltage_desc[] = {
31 "12 V",
32--
332.37.3
34
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0002-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0002-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch
deleted file mode 100644
index b8742b1a81..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0002-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch
+++ /dev/null
@@ -1,53 +0,0 @@
1From 81144cfba131b4ddbfcf9c530274b23bfc7e0ea8 Mon Sep 17 00:00:00 2001
2From: Chrostoper Ertl <chertl@microsoft.com>
3Date: Thu, 28 Nov 2019 16:51:49 +0000
4Subject: [PATCH 2/5] session: Fix buffer overflow in ipmi_get_session_info
5
6Partial fix for CVE-2020-5208, see
7https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
8
9The `ipmi_get_session_info` function does not properly check the
10response `data_len`, which is used as a copy size, allowing stack buffer
11overflow.
12
13Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/41d7026946fafbd4d1ec0bcaca3ea30a6e8eed22]
14CVE: CVE-2020-5208
15
16Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
17---
18 lib/ipmi_session.c | 12 ++++++++----
19 1 file changed, 8 insertions(+), 4 deletions(-)
20
21diff --git a/lib/ipmi_session.c b/lib/ipmi_session.c
22index 4855bc4..71bef4c 100644
23--- a/lib/ipmi_session.c
24+++ b/lib/ipmi_session.c
25@@ -319,8 +319,10 @@ ipmi_get_session_info(struct ipmi_intf * intf,
26 }
27 else
28 {
29- memcpy(&session_info, rsp->data, rsp->data_len);
30- print_session_info(&session_info, rsp->data_len);
31+ memcpy(&session_info, rsp->data,
32+ __min(rsp->data_len, sizeof(session_info)));
33+ print_session_info(&session_info,
34+ __min(rsp->data_len, sizeof(session_info)));
35 }
36 break;
37
38@@ -351,8 +353,10 @@ ipmi_get_session_info(struct ipmi_intf * intf,
39 break;
40 }
41
42- memcpy(&session_info, rsp->data, rsp->data_len);
43- print_session_info(&session_info, rsp->data_len);
44+ memcpy(&session_info, rsp->data,
45+ __min(rsp->data_len, sizeof(session_info)));
46+ print_session_info(&session_info,
47+ __min(rsp->data_len, sizeof(session_info)));
48
49 } while (i <= session_info.session_slot_count);
50 break;
51--
521.9.1
53
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0003-channel-Fix-buffer-overflow.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0003-channel-Fix-buffer-overflow.patch
deleted file mode 100644
index deebd356a7..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0003-channel-Fix-buffer-overflow.patch
+++ /dev/null
@@ -1,69 +0,0 @@
1From 5057761e30e3a7682edab60f98f631616392ddc6 Mon Sep 17 00:00:00 2001
2From: Chrostoper Ertl <chertl@microsoft.com>
3Date: Thu, 28 Nov 2019 16:56:38 +0000
4Subject: [PATCH 3/3] channel: Fix buffer overflow
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Partial fix for CVE-2020-5208, see
10https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
11
12The `ipmi_get_channel_cipher_suites` function does not properly check
13the final response’s `data_len`, which can lead to stack buffer overflow
14on the final copy.
15
16Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/9452be87181a6e83cfcc768b3ed8321763db50e4]
17CVE: CVE-2020-5208
18
19[Make some changes to apply it]
20Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
21---
22 include/ipmitool/ipmi_channel.h | 2 ++
23 lib/ipmi_channel.c | 10 ++++++++--
24 2 files changed, 10 insertions(+), 2 deletions(-)
25
26diff --git a/include/ipmitool/ipmi_channel.h b/include/ipmitool/ipmi_channel.h
27index b138c26..d7cce5e 100644
28--- a/include/ipmitool/ipmi_channel.h
29+++ b/include/ipmitool/ipmi_channel.h
30@@ -77,6 +77,8 @@ struct channel_access_t {
31 uint8_t user_level_auth;
32 };
33
34+#define MAX_CIPHER_SUITE_DATA_LEN 0x10
35+
36 /*
37 * The Get Authentication Capabilities response structure
38 * From table 22-15 of the IPMI v2.0 spec
39diff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c
40index fab2e54..76ecdcd 100644
41--- a/lib/ipmi_channel.c
42+++ b/lib/ipmi_channel.c
43@@ -378,7 +378,10 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type,
44 lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
45 return -1;
46 }
47- if (rsp->ccode > 0) {
48+ if (rsp->ccode
49+ || rsp->data_len < 1
50+ || rsp->data_len > sizeof(uint8_t) + MAX_CIPHER_SUITE_DATA_LEN)
51+ {
52 lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
53 val2str(rsp->ccode, completion_code_vals));
54 return -1;
55@@ -413,7 +416,10 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type,
56 lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
57 return -1;
58 }
59- if (rsp->ccode > 0) {
60+ if (rsp->ccode
61+ || rsp->data_len < 1
62+ || rsp->data_len > sizeof(uint8_t) + MAX_CIPHER_SUITE_DATA_LEN)
63+ {
64 lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
65 val2str(rsp->ccode, completion_code_vals));
66 return -1;
67--
682.18.1
69
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0004-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0004-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
deleted file mode 100644
index b5ce9e92ec..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0004-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
+++ /dev/null
@@ -1,94 +0,0 @@
1From e6aa6076f65e71544bd6450d20d943d7baaccb9f Mon Sep 17 00:00:00 2001
2From: Chrostoper Ertl <chertl@microsoft.com>
3Date: Thu, 28 Nov 2019 17:06:39 +0000
4Subject: [PATCH 4/5] lanp: Fix buffer overflows in get_lan_param_select
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Partial fix for CVE-2020-5208, see
10https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
11
12The `get_lan_param_select` function is missing a validation check on the
13response’s `data_len`, which it then returns to caller functions, where
14stack buffer overflow can occur.
15
16Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/d45572d71e70840e0d4c50bf48218492b79c1a10]
17CVE: CVE-2020-5208
18
19[Make some changes to apply it]
20Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
21---
22 lib/ipmi_lanp.c | 14 +++++++-------
23 1 file changed, 7 insertions(+), 7 deletions(-)
24
25diff --git a/lib/ipmi_lanp.c b/lib/ipmi_lanp.c
26index 060e753..dee21ee 100644
27--- a/lib/ipmi_lanp.c
28+++ b/lib/ipmi_lanp.c
29@@ -1917,7 +1917,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
30 if (p == NULL) {
31 return (-1);
32 }
33- memcpy(data, p->data, p->data_len);
34+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
35 /* set new ipaddr */
36 memcpy(data+3, temp, 4);
37 printf("Setting LAN Alert %d IP Address to %d.%d.%d.%d\n", alert,
38@@ -1932,7 +1932,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
39 if (p == NULL) {
40 return (-1);
41 }
42- memcpy(data, p->data, p->data_len);
43+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
44 /* set new macaddr */
45 memcpy(data+7, temp, 6);
46 printf("Setting LAN Alert %d MAC Address to "
47@@ -1947,7 +1947,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
48 if (p == NULL) {
49 return (-1);
50 }
51- memcpy(data, p->data, p->data_len);
52+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
53
54 if (strncasecmp(argv[1], "def", 3) == 0 ||
55 strncasecmp(argv[1], "default", 7) == 0) {
56@@ -1973,7 +1973,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
57 if (p == NULL) {
58 return (-1);
59 }
60- memcpy(data, p->data, p->data_len);
61+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
62
63 if (strncasecmp(argv[1], "on", 2) == 0 ||
64 strncasecmp(argv[1], "yes", 3) == 0) {
65@@ -1998,7 +1998,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
66 if (p == NULL) {
67 return (-1);
68 }
69- memcpy(data, p->data, p->data_len);
70+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
71
72 if (strncasecmp(argv[1], "pet", 3) == 0) {
73 printf("Setting LAN Alert %d destination to PET Trap\n", alert);
74@@ -2026,7 +2026,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
75 if (p == NULL) {
76 return (-1);
77 }
78- memcpy(data, p->data, p->data_len);
79+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
80
81 if (str2uchar(argv[1], &data[2]) != 0) {
82 lprintf(LOG_ERR, "Invalid time: %s", argv[1]);
83@@ -2042,7 +2042,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
84 if (p == NULL) {
85 return (-1);
86 }
87- memcpy(data, p->data, p->data_len);
88+ memcpy(data, p->data, __min(p->data_len, sizeof(data)));
89
90 if (str2uchar(argv[1], &data[3]) != 0) {
91 lprintf(LOG_ERR, "Invalid retry: %s", argv[1]);
92--
931.9.1
94
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-fru-sdr-Fix-id_string-buffer-overflows.patch b/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-fru-sdr-Fix-id_string-buffer-overflows.patch
deleted file mode 100644
index cf8b9254c8..0000000000
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool/0005-fru-sdr-Fix-id_string-buffer-overflows.patch
+++ /dev/null
@@ -1,142 +0,0 @@
1From 26e64ca78ae844c5ceedde89531e2924d7d4594c Mon Sep 17 00:00:00 2001
2From: Chrostoper Ertl <chertl@microsoft.com>
3Date: Thu, 28 Nov 2019 17:13:45 +0000
4Subject: [PATCH 5/5] fru, sdr: Fix id_string buffer overflows
5
6Final part of the fixes for CVE-2020-5208, see
7https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
8
99 variants of stack buffer overflow when parsing `id_string` field of
10SDR records returned from `CMD_GET_SDR` command.
11
12SDR record structs have an `id_code` field, and an `id_string` `char`
13array.
14
15The length of `id_string` is calculated as `(id_code & 0x1f) + 1`,
16which can be larger than expected 16 characters (if `id_code = 0xff`,
17then length will be `(0xff & 0x1f) + 1 = 32`).
18
19In numerous places, this can cause stack buffer overflow when copying
20into fixed buffer of size `17` bytes from this calculated length.
21
22Upstream-Status: Backport[https://github.com/ipmitool/ipmitool/commit/7ccea283dd62a05a320c1921e3d8d71a87772637]
23CVE: CVE-2020-5208
24
25Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
26---
27 lib/ipmi_fru.c | 2 +-
28 lib/ipmi_sdr.c | 40 ++++++++++++++++++++++++----------------
29 2 files changed, 25 insertions(+), 17 deletions(-)
30
31diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
32index b71ea23..1decea2 100644
33--- a/lib/ipmi_fru.c
34+++ b/lib/ipmi_fru.c
35@@ -3038,7 +3038,7 @@ ipmi_fru_print(struct ipmi_intf * intf, struct sdr_record_fru_locator * fru)
36 return 0;
37
38 memset(desc, 0, sizeof(desc));
39- memcpy(desc, fru->id_string, fru->id_code & 0x01f);
40+ memcpy(desc, fru->id_string, __min(fru->id_code & 0x01f, sizeof(desc)));
41 desc[fru->id_code & 0x01f] = 0;
42 printf("FRU Device Description : %s (ID %d)\n", desc, fru->device_id);
43
44diff --git a/lib/ipmi_sdr.c b/lib/ipmi_sdr.c
45index fa7b082..175a86f 100644
46--- a/lib/ipmi_sdr.c
47+++ b/lib/ipmi_sdr.c
48@@ -2113,7 +2113,7 @@ ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
49 return -1;
50
51 memset(desc, 0, sizeof (desc));
52- snprintf(desc, (sensor->id_code & 0x1f) + 1, "%s", sensor->id_string);
53+ snprintf(desc, sizeof(desc), "%.*s", (sensor->id_code & 0x1f) + 1, sensor->id_string);
54
55 if (verbose) {
56 printf("Sensor ID : %s (0x%x)\n",
57@@ -2164,7 +2164,7 @@ ipmi_sdr_print_sensor_mc_locator(struct ipmi_intf *intf,
58 return -1;
59
60 memset(desc, 0, sizeof (desc));
61- snprintf(desc, (mc->id_code & 0x1f) + 1, "%s", mc->id_string);
62+ snprintf(desc, sizeof(desc), "%.*s", (mc->id_code & 0x1f) + 1, mc->id_string);
63
64 if (verbose == 0) {
65 if (csv_output)
66@@ -2257,7 +2257,7 @@ ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
67 char desc[17];
68
69 memset(desc, 0, sizeof (desc));
70- snprintf(desc, (dev->id_code & 0x1f) + 1, "%s", dev->id_string);
71+ snprintf(desc, sizeof(desc), "%.*s", (dev->id_code & 0x1f) + 1, dev->id_string);
72
73 if (!verbose) {
74 if (csv_output)
75@@ -2314,7 +2314,7 @@ ipmi_sdr_print_sensor_fru_locator(struct ipmi_intf *intf,
76 char desc[17];
77
78 memset(desc, 0, sizeof (desc));
79- snprintf(desc, (fru->id_code & 0x1f) + 1, "%s", fru->id_string);
80+ snprintf(desc, sizeof(desc), "%.*s", (fru->id_code & 0x1f) + 1, fru->id_string);
81
82 if (!verbose) {
83 if (csv_output)
84@@ -2518,35 +2518,43 @@ ipmi_sdr_print_name_from_rawentry(struct ipmi_intf *intf,uint16_t id,
85
86 int rc =0;
87 char desc[17];
88+ const char *id_string;
89+ uint8_t id_code;
90 memset(desc, ' ', sizeof (desc));
91
92 switch ( type) {
93 case SDR_RECORD_TYPE_FULL_SENSOR:
94 record.full = (struct sdr_record_full_sensor *) raw;
95- snprintf(desc, (record.full->id_code & 0x1f) +1, "%s",
96- (const char *)record.full->id_string);
97+ id_code = record.full->id_code;
98+ id_string = record.full->id_string;
99 break;
100+
101 case SDR_RECORD_TYPE_COMPACT_SENSOR:
102 record.compact = (struct sdr_record_compact_sensor *) raw ;
103- snprintf(desc, (record.compact->id_code & 0x1f) +1, "%s",
104- (const char *)record.compact->id_string);
105+ id_code = record.compact->id_code;
106+ id_string = record.compact->id_string;
107 break;
108+
109 case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
110 record.eventonly = (struct sdr_record_eventonly_sensor *) raw ;
111- snprintf(desc, (record.eventonly->id_code & 0x1f) +1, "%s",
112- (const char *)record.eventonly->id_string);
113- break;
114+ id_code = record.eventonly->id_code;
115+ id_string = record.eventonly->id_string;
116+ break;
117+
118 case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:
119 record.mcloc = (struct sdr_record_mc_locator *) raw ;
120- snprintf(desc, (record.mcloc->id_code & 0x1f) +1, "%s",
121- (const char *)record.mcloc->id_string);
122+ id_code = record.mcloc->id_code;
123+ id_string = record.mcloc->id_string;
124 break;
125+
126 default:
127 rc = -1;
128- break;
129- }
130+ }
131+ if (!rc) {
132+ snprintf(desc, sizeof(desc), "%.*s", (id_code & 0x1f) + 1, id_string);
133+ }
134
135- lprintf(LOG_INFO, "ID: 0x%04x , NAME: %-16s", id, desc);
136+ lprintf(LOG_INFO, "ID: 0x%04x , NAME: %-16s", id, desc);
137 return rc;
138 }
139
140--
1411.9.1
142
diff --git a/meta-oe/recipes-kernel/ipmitool/ipmitool_1.8.18.bb b/meta-oe/recipes-kernel/ipmitool/ipmitool_1.8.19.bb
index 3337fe5006..0a600e23bb 100644
--- a/meta-oe/recipes-kernel/ipmitool/ipmitool_1.8.18.bb
+++ b/meta-oe/recipes-kernel/ipmitool/ipmitool_1.8.19.bb
@@ -21,24 +21,31 @@ LICENSE = "BSD-3-Clause"
21LIC_FILES_CHKSUM = "file://COPYING;md5=9aa91e13d644326bf281924212862184" 21LIC_FILES_CHKSUM = "file://COPYING;md5=9aa91e13d644326bf281924212862184"
22 22
23DEPENDS = "openssl readline ncurses" 23DEPENDS = "openssl readline ncurses"
24 24SRCREV = "19d78782d795d0cf4ceefe655f616210c9143e62"
25SRC_URI = "${SOURCEFORGE_MIRROR}/ipmitool/ipmitool-${PV}.tar.bz2 \ 25SRC_URI = "git://github.com/ipmitool/ipmitool;protocol=https;branch=master \
26 file://0001-Migrate-to-openssl-1.1.patch \ 26 ${IANA_ENTERPRISE_NUMBERS} \
27 file://0001-fru-Fix-buffer-overflow-vulnerabilities.patch \ 27 file://0001-ipmi_fru.c-Provide-missing-function-declarations.patch \
28 file://0001-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch \ 28 file://0001-configure-Remove-the-logic-to-download-IANA-PEN-data.patch \
29 file://0002-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch \
30 file://0003-channel-Fix-buffer-overflow.patch \
31 file://0004-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch \
32 file://0005-fru-sdr-Fix-id_string-buffer-overflows.patch \
33 file://0001-hpmfwupg-move-variable-definition-to-.c-file.patch \
34 " 29 "
35SRC_URI[md5sum] = "bab7ea104c7b85529c3ef65c54427aa3" 30IANA_ENTERPRISE_NUMBERS ?= ""
36SRC_URI[sha256sum] = "0c1ba3b1555edefb7c32ae8cd6a3e04322056bc087918f07189eeedfc8b81e01" 31
32# Add these via bbappend if this database is needed by the system
33#IANA_ENTERPRISE_NUMBERS ?= "http://www.iana.org/assignments/enterprise-numbers;name=iana-enterprise-numbers;downloadfilename=iana-enterprise-numbers"
34#SRC_URI[iana-enterprise-numbers.sha256sum] = "cdd97fc08325667434b805eb589104ae63f7a9eb720ecea73cb55110b383934c"
35
36S = "${WORKDIR}/git"
37 37
38inherit autotools 38inherit autotools
39 39
40do_install:append() {
41 if [ -e ${WORKDIR}/iana-enterprise-numbers ]; then
42 install -Dm 0755 ${WORKDIR}/iana-enterprise-numbers ${D}${datadir}/misc/enterprise-numbers
43 fi
44}
45
40PACKAGES =+ "${PN}-ipmievd" 46PACKAGES =+ "${PN}-ipmievd"
41FILES:${PN}-ipmievd += "${sbindir}/ipmievd" 47FILES:${PN}-ipmievd += "${sbindir}/ipmievd"
48FILES:${PN} += "${datadir}/misc"
42 49
43# --disable-dependency-tracking speeds up the build 50# --disable-dependency-tracking speeds up the build
44# --enable-file-security adds some security checks 51# --enable-file-security adds some security checks