opnsense-src/sys/dev/pci
Stefan Eßer f01c863337 dev/pci: fix potential panic due to bogus VPD data
A panic has been observed on a system with a Intel X520 dual LAN
device. The panic is caused by a KASSERT() noticing that the amount
of VPD data copied out to the pciconf command does not match the
amount of data read from the device.

The cause of the size mismatch was VPD data that started with 0x82,
the VPD tag that indicates that a VPD ident follows, but with a length
of more than 255 characters, which happens to be the maximum ident
size supported by the API between kernel and the pciconf program.
The data provided did not resemble an actual VPD identifier, and it
can be assumed that the initial tag value 0x82 happens to be there
by accident.

An ident size of 255 far exceeds the sensible length of that data
element, which is in the order of at most 30 to 40 bytes.

This patch adds several consitstency checks to the VPD parser, the
most critical being that ident lengths of more than 255 bytes are
rejected. Other checks reject VPD with more than one ident tag or
with an empty (zero length) ident string.

This patch prevents the panic that occured when "pciconf -lV" was
executed on the affected system.

During the anaylsis of the issue and the VPD code it has been
found that the VPD parser uses a state machine that accepts tags
in any order and combination. This is a bad match for the actual
VPD data, which has a very simple structure that can be parsed
with a non-recursive direct descent parser (which always knows
exactly which token to expect next).

A review fpr a much simpler VPD parser that performs many more
consistency checks and rejects invalid VPD has been proposed in
review https://reviews.freebsd.org/D34268.

Reported by:	mikej at paymentallianceintl.com (Michael Jung)
Approved by:	jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D34255
2022-02-20 22:36:04 +01:00
..
controller Use pmap_qenter in the N1SDP PCIe driver 2021-02-25 12:38:05 +00:00
fixup_pci.c sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
hostb_pci.c pci: clean up empty lines in .c and .h files 2020-09-01 22:00:07 +00:00
ignore_pci.c sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
isa_pci.c pci: clean up empty lines in .c and .h files 2020-09-01 22:00:07 +00:00
pci.c dev/pci: fix potential panic due to bogus VPD data 2022-02-20 22:36:04 +01:00
pci_dw.c pci_dw: Drop unconditional explicit DEBUG define 2021-08-07 21:25:36 +01:00
pci_dw.h pci_dw: Detect number of outbound regions automatically 2021-07-21 05:51:20 +01:00
pci_dw_if.m Add driver for DesignWare PCIE core, and its Armada 8K specific attachement. 2019-10-20 11:11:32 +00:00
pci_dw_mv.c pci_dw_mv: Don't enable unhandled interrupts. 2021-03-01 14:03:34 +01:00
pci_host_generic.c bus: Make BUS_TRANSLATE_RESOURCE behave more like other bus methods 2021-11-15 13:01:30 -05:00
pci_host_generic.h pci_host_generic: Add Synopsys Designware PCIe controller quirk 2021-09-15 15:17:40 +02:00
pci_host_generic_acpi.c pci_host_generic: update Synopsys device description for ACPI 2021-09-16 16:53:11 +02:00
pci_host_generic_acpi.h Add PCI Express driver for the ARM Neoverse N1 System Development 2020-02-11 15:12:09 +00:00
pci_host_generic_fdt.c pci_host_generic: Add Synopsys Designware PCIe controller quirk 2021-09-15 15:17:40 +02:00
pci_host_generic_fdt.h pci_host_generic_fdt.c: Add support for mapping dts nodes to PCI devices 2021-06-08 17:51:40 +02:00
pci_if.m Add PCI methods to iterate over the PCI capabilities 2018-02-19 18:41:56 +00:00
pci_iov.c pci: Implement pci_bar_enabled() for SR-IOV VFs 2021-11-09 13:13:36 -05:00
pci_iov.h Permit the name of the /dev/iov entry to be set by the driver. 2016-08-03 17:09:12 +00:00
pci_iov_if.m Create a separate kobj interface for leaf-driver PCI IOV methods. 2015-05-28 22:01:50 +00:00
pci_iov_private.h pci: Implement pci_bar_enabled() for SR-IOV VFs 2021-11-09 13:13:36 -05:00
pci_iov_schema.c Clean up repeated "All rights reserved" 2016-03-14 17:41:17 +00:00
pci_pci.c Create wrapper for Giant taken for newbus 2021-12-09 17:04:45 -07:00
pci_private.h LinuxKPI: Support lazy BAR allocation 2021-10-17 15:32:35 +01:00
pci_subr.c sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
pci_user.c dev/pci: fix potential panic due to bogus VPD data 2022-02-20 22:36:04 +01:00
pcib_if.m Create pcib_request_feature. 2017-02-25 06:11:36 +00:00
pcib_private.h pcib(4): Switch from callout to timeout_task. 2021-09-03 15:03:44 -04:00
pcib_support.c pci: clean up empty lines in .c and .h files 2020-09-01 22:00:07 +00:00
pcireg.h Add more values for PCI capabilities, PCIe extended capabilities, and subclasses. 2020-02-20 17:08:52 +00:00
pcivar.h Implement pci_get_relaxed_ordering_enabled() helper function. 2021-03-17 13:48:04 +01:00
schema_private.h Clean up repeated "All rights reserved" 2016-03-14 17:41:17 +00:00
vga_pci.c pci: clean up empty lines in .c and .h files 2020-09-01 22:00:07 +00:00