]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: validate pcie_cap_pos != 0 in virDeviceHasPCIExpressLink()
authorLaine Stump <laine@redhat.com>
Wed, 6 Jan 2021 20:42:47 +0000 (15:42 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 8 Jan 2021 00:41:27 +0000 (19:41 -0500)
commit49b5ebad9c597a8caa767d55987201d3fb022056
treea81b59672efd30686b04afad425d0618286a6156
parent2d0bac9d58775ef50c76beedfb9b4a4f80af1d55
util: validate pcie_cap_pos != 0 in virDeviceHasPCIExpressLink()

virDeviceHasPCIExpressLink() wasn't checking that pcie_cap_pos was
valid before attempting to use it, which could lead to reading the
byte at offset 0 + PCI_CAP_ID_EXP instead of [valid offset] +
PCI_CAP_ID_EXP. In particular, this could happen for "integrated" PCI
devices (those that are on the PCIe root complex). If it happened that
the byte from the wrong address had the "right" bit set, then it would
lead to us innappropriately believing that Express Link info was
available when it wasn't, and the node device driver would then log an
error like this:

  virPCIDeviceGetLinkCapSta:2754 :
  internal error: pci device 0000:00:18.0 is not a PCI-Express device

during a libvirtd restart. (this didn't ever occur until after
virPCIDeviceIsPCIExpress() was made more intelligent in commit
c00b6b1ae, which hasn't yet been in any official release)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virpci.c