Skip to content

Commit

Permalink
ehci: apply limit to iTD/sidt descriptors
Browse files Browse the repository at this point in the history
Commit "156a2e4 ehci: make idt processing more robust" tries to avoid a
DoS by the guest (create a circular iTD queue and let qemu ehci
emulation run in circles forever).  Unfortunately this has two problems:
First it misses the case of siTDs, and second it reportedly breaks
FreeBSD.

So lets go for a different approach: just count the number of iTDs and
siTDs we have seen per frame and apply a limit.  That should really
catch all cases now.

Reported-by: 杜少博 <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
  • Loading branch information
kraxel committed Apr 19, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent c6c598c commit 1ae3f2f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hw/usb/hcd-ehci.c
Original file line number Diff line number Diff line change
@@ -2011,6 +2011,7 @@ static int ehci_state_writeback(EHCIQueue *q)
static void ehci_advance_state(EHCIState *ehci, int async)
{
EHCIQueue *q = NULL;
int itd_count = 0;
int again;

do {
@@ -2035,10 +2036,12 @@ static void ehci_advance_state(EHCIState *ehci, int async)

case EST_FETCHITD:
again = ehci_state_fetchitd(ehci, async);
itd_count++;
break;

case EST_FETCHSITD:
again = ehci_state_fetchsitd(ehci, async);
itd_count++;
break;

case EST_ADVANCEQUEUE:
@@ -2087,7 +2090,8 @@ static void ehci_advance_state(EHCIState *ehci, int async)
break;
}

if (again < 0) {
if (again < 0 || itd_count > 16) {
/* TODO: notify guest (raise HSE irq?) */
fprintf(stderr, "processing error - resetting ehci HC\n");
ehci_reset(ehci);
again = 0;

0 comments on commit 1ae3f2f

Please sign in to comment.