usb/xchi: avoid trigger assertion if guest write wrong epid
PATCH v2 1/1 usb/xchi: avoid trigger assertion if guest write wrong epid
From: Longpeng <[email protected]>
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 (...) 5 0x000000000047897a in memory_region_write_accessor (...) 6 0x000000000047767f in access_with_adjusted_size (...) 7 0x000000000047944d in memory_region_dispatch_write (...)
(mr=mr@entry=0x7fc6a0138df0, addr=addr@entry=156, data=1648892416, size=size@entry=4, attrs=attrs@entry=...)
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) f 5
5 0x000000000047897a in memory_region_write_accessor (...)
529 mr->ops->write(mr->opaque, addr, tmp, size);
(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.
---
v1 -> v2:
1) update the description, include the full backtrace
2) remove unnecessary check: 'reg == 0'
--- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-xhci.c +1 -1
@@ -3137,7 +3137,7 @@ static void xhci_doorbell_write(void *ptr, hwaddr reg, streamid = (val >>16 ) &0xffff ;if (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 {
Signature · 1 line
1.8.3.1
Quoted 28 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
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 (...) 5 0x000000000047897a in memory_region_write_accessor (...) 6 0x000000000047767f in access_with_adjusted_size (...) 7 0x000000000047944d in memory_region_dispatch_write (...)(mr=mr@entry=0x7fc6a0138df0, addr=addr@entry=156, data=1648892416, size=size@entry=4, attrs=attrs@entry=...)
80x000000000042df17inaddress_space_write_continue(...)
100x000000000043084dinaddress_space_rw(...)
110x000000000047451binkvm_cpu_exec(cpu=cpu@entry=0x1ab11b0) 120x000000000045dcf5inqemu_kvm_cpu_thread_fn(arg=0x1ab11b0) 130x0000000000870631inqemu_thread_start(args=args@entry=0x1acfb50) 140x00000000008959a7inthread_entry_for_hotfix(pthread_cb=<optimized out>) 150x00007fc6b0a60dd5instart_thread()
160x00007fc6b078a59din clone ()(gdb) f 5
50x000000000047897ainmemory_region_write_accessor(...)
529mr->ops->write(mr->opaque, addr, tmp, size);
(gdb) p /x tmp
$9 =0x62481a00<-- last byte0x00is @epid
Quoted 6 lines
xhci_doorbell_write()already check the upper bound of @slotid an @epid, it also need to check the lower bound.Cc Gonglei <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Longpeng <[email protected]>
Quoted 23 lines
---
v1 -> v2:
1) update the description, include the full backtrace
2) remove unnecessary check: 'reg == 0'--- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/usb/hcd-xhci.c +1
-1@@ -3137,7 +3137,7 @@ static void xhci_doorbell_write(void *ptr, hwaddr reg, streamid = (val >>16 ) &0xffff ;if (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 {
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 28 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
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 (...) 5 0x000000000047897a in memory_region_write_accessor (...) 6 0x000000000047767f in access_with_adjusted_size (...) 7 0x000000000047944d in memory_region_dispatch_write (...)(mr=mr@entry=0x7fc6a0138df0, addr=addr@entry=156, data=1648892416, size=size@entry=4, attrs=attrs@entry=...)
80x000000000042df17inaddress_space_write_continue(...)
100x000000000043084dinaddress_space_rw(...)
110x000000000047451binkvm_cpu_exec(cpu=cpu@entry=0x1ab11b0) 120x000000000045dcf5inqemu_kvm_cpu_thread_fn(arg=0x1ab11b0) 130x0000000000870631inqemu_thread_start(args=args@entry=0x1acfb50) 140x00000000008959a7inthread_entry_for_hotfix(pthread_cb=<optimized out>) 150x00007fc6b0a60dd5instart_thread()
160x00007fc6b078a59din clone ()(gdb) f 5
50x000000000047897ainmemory_region_write_accessor(...)
529mr->ops->write(mr->opaque, addr, tmp, size);
(gdb) p /x tmp
$9 =0x62481a00<-- last byte0x00is @epid
Quoted 6 lines
xhci_doorbell_write()already check the upper bound of @slotid an @epid, it also need to check the lower bound.Cc Gonglei <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Longpeng <[email protected]>
Added to usb queue.
thanks,
Gerd