You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.1 KiB

  1. From e048e9c65a52f0879d482531e70735c1d314d43a Mon Sep 17 00:00:00 2001
  2. From: Chrostoper Ertl <chertl@microsoft.com>
  3. Date: Thu, 28 Nov 2019 17:06:39 +0000
  4. Subject: [PATCH 10/11] lanp: Fix buffer overflows in get_lan_param_select
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Partial fix for CVE-2020-5208, see
  9. https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
  10. The `get_lan_param_select` function is missing a validation check on the
  11. response’s `data_len`, which it then returns to caller functions, where
  12. stack buffer overflow can occur.
  13. ---
  14. lib/ipmi_lanp.c | 14 +++++++-------
  15. 1 file changed, 7 insertions(+), 7 deletions(-)
  16. diff --git a/lib/ipmi_lanp.c b/lib/ipmi_lanp.c
  17. index 65d881bc5890..022c7f1605ed 100644
  18. --- a/lib/ipmi_lanp.c
  19. +++ b/lib/ipmi_lanp.c
  20. @@ -1809,7 +1809,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
  21. if (p == NULL) {
  22. return (-1);
  23. }
  24. - memcpy(data, p->data, p->data_len);
  25. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  26. /* set new ipaddr */
  27. memcpy(data+3, temp, 4);
  28. printf("Setting LAN Alert %d IP Address to %d.%d.%d.%d\n", alert,
  29. @@ -1824,7 +1824,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 macaddr */
  36. memcpy(data+7, temp, 6);
  37. printf("Setting LAN Alert %d MAC Address to "
  38. @@ -1838,7 +1838,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. if (strncasecmp(argv[1], "def", 3) == 0 ||
  45. strncasecmp(argv[1], "default", 7) == 0) {
  46. @@ -1864,7 +1864,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
  47. if (p == NULL) {
  48. return (-1);
  49. }
  50. - memcpy(data, p->data, p->data_len);
  51. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  52. if (strncasecmp(argv[1], "on", 2) == 0 ||
  53. strncasecmp(argv[1], "yes", 3) == 0) {
  54. @@ -1889,7 +1889,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
  55. if (p == NULL) {
  56. return (-1);
  57. }
  58. - memcpy(data, p->data, p->data_len);
  59. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  60. if (strncasecmp(argv[1], "pet", 3) == 0) {
  61. printf("Setting LAN Alert %d destination to PET Trap\n", alert);
  62. @@ -1917,7 +1917,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
  63. if (p == NULL) {
  64. return (-1);
  65. }
  66. - memcpy(data, p->data, p->data_len);
  67. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  68. if (str2uchar(argv[1], &data[2]) != 0) {
  69. lprintf(LOG_ERR, "Invalid time: %s", argv[1]);
  70. @@ -1933,7 +1933,7 @@ ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
  71. if (p == NULL) {
  72. return (-1);
  73. }
  74. - memcpy(data, p->data, p->data_len);
  75. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  76. if (str2uchar(argv[1], &data[3]) != 0) {
  77. lprintf(LOG_ERR, "Invalid retry: %s", argv[1]);
  78. --
  79. 2.27.0