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.

43 lines
1.4 KiB

  1. From 910e5782b7d9f222d4e34d3505d0d636ff757103 Mon Sep 17 00:00:00 2001
  2. From: Chrostoper Ertl <chertl@microsoft.com>
  3. Date: Thu, 28 Nov 2019 16:44:18 +0000
  4. Subject: [PATCH 07/11] fru: Fix buffer overflow in ipmi_spd_print_fru
  5. Partial fix for CVE-2020-5208, see
  6. https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
  7. The `ipmi_spd_print_fru` function has a similar issue as the one fixed
  8. by the previous commit in `read_fru_area_section`. An initial request is
  9. made to get the `fru.size`, which is used as the size for the allocation
  10. of `spd_data`. Inside a loop, further requests are performed to get the
  11. copy sizes which are not checked before being used as the size for a
  12. copy into the buffer.
  13. ---
  14. lib/dimm_spd.c | 9 ++++++++-
  15. 1 file changed, 8 insertions(+), 1 deletion(-)
  16. --- a/lib/dimm_spd.c
  17. +++ b/lib/dimm_spd.c
  18. @@ -1621,7 +1621,7 @@ ipmi_spd_print_fru(struct ipmi_intf * in
  19. struct ipmi_rq req;
  20. struct fru_info fru;
  21. uint8_t *spd_data, msg_data[4];
  22. - int len, offset;
  23. + uint32_t len, offset;
  24. msg_data[0] = id;
  25. @@ -1697,6 +1697,13 @@ ipmi_spd_print_fru(struct ipmi_intf * in
  26. }
  27. len = rsp->data[0];
  28. + if(rsp->data_len < 1
  29. + || len > rsp->data_len - 1
  30. + || len > fru.size - offset)
  31. + {
  32. + printf(" Not enough buffer size");
  33. + return -1;
  34. + }
  35. memcpy(&spd_data[offset], rsp->data + 1, len);
  36. offset += len;
  37. } while (offset < fru.size);