qemu-2.8.0-CVE-2017-5987.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From: Prasad J Pandit <address@hidden>
  2. In the SDHCI protocol, the transfer mode register value
  3. is used during multi block transfer to check if block count
  4. register is enabled and should be updated. Transfer mode
  5. register could be set such that, block count register would
  6. not be updated, thus leading to an infinite loop. Add check
  7. to avoid it.
  8. Reported-by: Wjjzhang <address@hidden>
  9. Reported-by: Jiang Xin <address@hidden>
  10. Signed-off-by: Prasad J Pandit <address@hidden>
  11. ---
  12. hw/sd/sdhci.c | 10 +++++-----
  13. 1 file changed, 5 insertions(+), 5 deletions(-)
  14. Update: use qemu_log_mask(LOG_UNIMP, ...)
  15. -> https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg02354.html
  16. diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
  17. index 5bd5ab6..a9c744b 100644
  18. --- a/hw/sd/sdhci.c
  19. +++ b/hw/sd/sdhci.c
  20. @@ -486,6 +486,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
  21. uint32_t boundary_chk = 1 << (((s->blksize & 0xf000) >> 12) + 12);
  22. uint32_t boundary_count = boundary_chk - (s->sdmasysad % boundary_chk);
  23. + if (!(s->trnmod & SDHC_TRNS_BLK_CNT_EN) || !s->blkcnt) {
  24. + qemu_log_mask(LOG_UNIMP, "infinite transfer is not supported\n");
  25. + return;
  26. + }
  27. +
  28. /* XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for
  29. * possible stop at page boundary if initial address is not page aligned,
  30. * allow them to work properly */
  31. @@ -797,11 +802,6 @@ static void sdhci_data_transfer(void *opaque)
  32. if (s->trnmod & SDHC_TRNS_DMA) {
  33. switch (SDHC_DMA_TYPE(s->hostctl)) {
  34. case SDHC_CTRL_SDMA:
  35. - if ((s->trnmod & SDHC_TRNS_MULTI) &&
  36. - (!(s->trnmod & SDHC_TRNS_BLK_CNT_EN) || s->blkcnt == 0)) {
  37. - break;
  38. - }
  39. -
  40. if ((s->blkcnt == 1) || !(s->trnmod & SDHC_TRNS_MULTI)) {
  41. sdhci_sdma_transfer_single_block(s);
  42. } else {
  43. --
  44. 2.9.3