All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] usb/xchi: avoid trigger assertion if guest write wrong epid
@ 2019-04-29  7:39 ` Longpeng(Mike)
  0 siblings, 0 replies; 19+ messages in thread
From: Longpeng(Mike) @ 2019-04-29  7:39 UTC (permalink / raw)
  To: kraxel; +Cc: qemu-devel, Longpeng, Gonglei

From: Longpeng <longpeng2@huawei.com>

we found the following core in our environment:
0  0x00007fc6b06c2237 in raise ()
1  0x00007fc6b06c3928 in abort ()
2  0x00007fc6b06bb056 in __assert_fail_base ()
3  0x00007fc6b06bb102 in __assert_fail ()
4  0x0000000000702e36 in xhci_kick_ep (...)
6  0x000000000047767f in access_with_adjusted_size (...)
7  0x000000000047944d in memory_region_dispatch_write (...)
8  0x000000000042df17 in address_space_write_continue (...)
10 0x000000000043084d in address_space_rw (...)
11 0x000000000047451b in kvm_cpu_exec (cpu=cpu@entry=0x1ab11b0)
12 0x000000000045dcf5 in qemu_kvm_cpu_thread_fn (arg=0x1ab11b0)
13 0x0000000000870631 in qemu_thread_start (args=args@entry=0x1acfb50)
14 0x00000000008959a7 in thread_entry_for_hotfix (pthread_cb=<optimized out>)
15 0x00007fc6b0a60dd5 in start_thread ()
16 0x00007fc6b078a59d in clone ()
(gdb) bt
(gdb) f 5
(gdb) p /x tmp
$9 = 0x62481a00 <-- last byte 0x00 is @epid

xhci_doorbell_write() already check the upper bound of @slotid an @epid,
it also need to check the lower bound.

Cc: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Longpeng <longpeng2@huawei.com>
---
 hw/usb/hcd-xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index ec28bee..b4e6bfc 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3135,9 +3135,9 @@ static void xhci_doorbell_write(void *ptr, hwaddr reg,
     } else {
         epid = val & 0xff;
         streamid = (val >> 16) & 0xffff;
-        if (reg > xhci->numslots) {
+        if (reg == 0 || reg > xhci->numslots) {
             DPRINTF("xhci: bad doorbell %d\n", (int)reg);
-        } else if (epid > 31) {
+        } else if (epid == 0 || epid > 31) {
             DPRINTF("xhci: bad doorbell %d write: 0x%x\n",
                     (int)reg, (uint32_t)val);
         } else {
-- 
1.8.3.1

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

end of thread, other threads:[~2019-04-30  5:38 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29  7:39 [Qemu-devel] [PATCH] usb/xchi: avoid trigger assertion if guest write wrong epid Longpeng(Mike)
2019-04-29  7:39 ` Longpeng(Mike)
2019-04-29 11:16 ` Philippe Mathieu-Daudé
2019-04-29 11:42   ` Longpeng (Mike)
2019-04-29 11:42     ` Longpeng (Mike)
2019-04-29 12:10     ` Philippe Mathieu-Daudé
2019-04-29 12:10       ` Philippe Mathieu-Daudé
2019-04-30  2:02       ` Longpeng (Mike)
2019-04-30  2:02         ` Longpeng (Mike)
2019-04-30  5:06         ` Philippe Mathieu-Daudé
2019-04-30  5:06           ` Philippe Mathieu-Daudé
2019-04-30  5:37           ` Longpeng (Mike)
2019-04-30  5:37             ` Longpeng (Mike)
2019-04-29 15:05 ` no-reply
2019-04-29 15:05   ` no-reply
2019-04-29 15:10   ` Philippe Mathieu-Daudé
2019-04-29 15:10     ` Philippe Mathieu-Daudé
2019-04-29 17:58 ` no-reply
2019-04-29 17:58   ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.