Skip to content

Commit 89140fd

Browse files
Joe Lawrencegregkh
authored andcommitted
xhci: harden xhci_find_next_ext_cap against device removal
xhci_find_next_ext_cap doesn't check for PCI hotplug removal and may use the PCI master abort bit pattern (~0) to calculate a new PCI address offset to read/write. The has lead to reproducable crashes when testing surprise removal during device initialization on a Stratus platform, at least after commit d5ddcdf ("xhci: rework xhci extended capability list parsing functions"). The crash is repeatable on a Stratus platform when injecting hardware faults to induce xHCI host controller hotplug during driver initialization. If a PCI read in xhci_find_next_ext_cap returns the master abort pattern, quirk_usb_handoff_xhci may start using a bogus ext_cap_offset to start searching more bogus PCI addresses. Signed-off-by: Joe Lawrence <[email protected]> Acked-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 207b08b commit 89140fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/usb/host/xhci-ext-caps.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ static inline int xhci_find_next_ext_cap(void __iomem *base, u32 start, int id)
112112
offset = start;
113113
if (!start || start == XHCI_HCC_PARAMS_OFFSET) {
114114
val = readl(base + XHCI_HCC_PARAMS_OFFSET);
115+
if (val == ~0)
116+
return 0;
115117
offset = XHCI_HCC_EXT_CAPS(val) << 2;
116118
if (!offset)
117119
return 0;
118120
};
119121
do {
120122
val = readl(base + offset);
123+
if (val == ~0)
124+
return 0;
121125
if (XHCI_EXT_CAPS_ID(val) == id && offset != start)
122126
return offset;
123127

0 commit comments

Comments
 (0)