• David Daney's avatar
    PCI/AER: Restore pci_ops pointer while calling original pci_ops · 7e8fbdc6
    David Daney authored
    The aer_inject module intercepts config space accesses by replacing the
    bus->ops pointer.  If it forwards accesses to the original pci_ops, and
    those original ops use bus->ops, they see the aer_pci_ops instead of their
    own pci_ops, which can cause a crash.
    
    For example, pci_generic_config_read() uses the bus->ops->map_bus pointer.
    If bus->ops is set to aer_pci_ops, which doesn't supply .map_bus,
    pci_generic_config_read() will dereference an invalid pointer and cause a
    crash.
    
    Temporarily restore the original bus->ops pointer while calling ops->read()
    or ops->write().  Callers of these functions already hold pci_lock, which
    prevents other users of bus->ops until we're finished.
    
    [bhelgaas: changelog]
    Signed-off-by: default avatarDavid Daney <david.daney@cavium.com>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    7e8fbdc6
aer_inject.c 13.2 KB