qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] ati-vga: check address before reading configuration bytes (CVE-2020-13791)
@ 2020-06-04 10:55 P J P
  2020-06-04 11:49 ` Michael S. Tsirkin
  0 siblings, 1 reply; 7+ messages in thread
From: P J P @ 2020-06-04 10:55 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Daniel P . Berrangé, Prasad J Pandit, Michael S . Tsirkin,
	Yi Ren, QEMU Developers, Ren Ding, Philippe Mathieu-Daudé,
	Hanqing Zhao

From: Prasad J Pandit <pjp@fedoraproject.org>

While reading PCI configuration bytes, a guest may send an
address towards the end of the configuration space. It may lead
to an OOB access issue. Add check to ensure 'address + size' is
within PCI configuration space.

Reported-by: Ren Ding <rding@gatech.edu>
Reported-by: Hanqing Zhao <hanqing@gatech.edu>
Reported-by: Yi Ren <c4tren@gmail.com>
Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/display/ati.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Update v3: avoid modifying 'addr' variable
  -> https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00834.html

diff --git a/hw/display/ati.c b/hw/display/ati.c
index 67604e68de..b4d0fd88b7 100644
--- a/hw/display/ati.c
+++ b/hw/display/ati.c
@@ -387,7 +387,9 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
         val = s->regs.crtc_pitch;
         break;
     case 0xf00 ... 0xfff:
-        val = pci_default_read_config(&s->dev, addr - 0xf00, size);
+        if ((addr - 0xf00) + size <= pci_config_size(&s->dev)) {
+            val = pci_default_read_config(&s->dev, addr - 0xf00, size);
+        }
         break;
     case CUR_OFFSET:
         val = s->regs.cur_offset;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-02  9:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-04 10:55 [PATCH v3] ati-vga: check address before reading configuration bytes (CVE-2020-13791) P J P
2020-06-04 11:49 ` Michael S. Tsirkin
2020-06-04 11:56   ` Philippe Mathieu-Daudé
2020-06-04 12:00     ` Michael S. Tsirkin
2020-07-02  7:54       ` Michael Tokarev
2020-07-02  9:36         ` Paolo Bonzini
2020-06-04 12:01   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).