Page MenuHomeFreeBSD

bhyve: Fix handling of the xhci event ring
Needs ReviewPublic

Authored by markj on Mon, Oct 12, 6:39 PM.
Tags
None
Referenced Files
F175750384: D60677.diff
Tue, Oct 13, 12:55 AM
F175747691: D60677.id189656.diff
Tue, Oct 13, 12:22 AM
F175743916: D60677.diff
Mon, Oct 12, 11:37 PM
Subscribers

Details

Reviewers
aokblast
kevans
Group Reviewers
bhyve
Summary

rts->erst_p and rts->erstba_p are pointers to guest-controlled memory
which describe the event rings and pending event array, respectively.
The device model was not validating the size nor saving the value.
As a result, the bounds checks in pci_xhci_insert_event() were
susceptible to TOCTOU races.

Fix pci_xhci_rtsregs_write() to save the ring size in a softc field.
Validate that the size isn't larger than the maximum allowed by the XHCI
specification (64KB, or 4096 TRBs).

When processing TRBs, make sure we don't load fields more than once.
Make sure that pci_xhci_trb_next() doesn't return a pointer to host
memory. When handling ERDP writes, make sure that the guest-supplied
address is actually a pointer into the TRB array, and ignore the write
if not.

Reported by: Brian Delgado from Intel using Anthropic Opus 4.8

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 78095
Build 74978: arc lint + arc unit