qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/usb/hcd-dwc2: fix divide-by-zero in dwc2_handle_packet()
@ 2020-10-12 15:03 Mauro Matteo Cascella
  2020-10-12 20:34 ` Paul Zimmerman
  0 siblings, 1 reply; 9+ messages in thread
From: Mauro Matteo Cascella @ 2020-10-12 15:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: gaoning.pgn, mcascell, linyi.lxw, kraxel, pauldzim

Check the value of mps before it is used as divisor. Since HCCHAR_MPS is guest
controllable, this prevents a malicious/buggy guest from crashing the QEMU
process on the host.

Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Reported-by: Gaoning Pan <gaoning.pgn@antgroup.com>
Reported-by: Xingwei Lin <linyi.lxw@antfin.com>
---
 hw/usb/hcd-dwc2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index 97688d21bf..91476fd781 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -324,6 +324,12 @@ babble:
             }
         }
 
+        if (mps == 0) {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                    "%s: Bad HCCHAR_MPS set to zero\n", __func__);
+            return;
+        }
+
         tpcnt = actual / mps;
         if (actual % mps) {
             tpcnt++;
-- 
2.26.2



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

end of thread, other threads:[~2020-10-15 10:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-12 15:03 [PATCH] hw/usb/hcd-dwc2: fix divide-by-zero in dwc2_handle_packet() Mauro Matteo Cascella
2020-10-12 20:34 ` Paul Zimmerman
2020-10-13  7:04   ` Gerd Hoffmann
2020-10-13  7:19     ` Paul Zimmerman
2020-10-13  8:41       ` Gerd Hoffmann
2020-10-14 19:55         ` Mauro Matteo Cascella
2020-10-15  7:35           ` Paul Zimmerman
2020-10-15 10:17             ` Gerd Hoffmann
2020-10-14 12:06       ` Gerd Hoffmann

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).