OpenCloudOS-Kernel/drivers/pci
Sean Anderson 02a370c4fc PCI: xilinx-nwl: Fix off-by-one in INTx IRQ handler
commit 0199d2f2bd8cd97b310f7ed82a067247d7456029 upstream.

MSGF_LEG_MASK is laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2,
and INTD in bit 3. Hardware IRQ numbers start at 0, and we register
PCI_NUM_INTX IRQs. So to enable INTA (aka hwirq 0) we should set bit 0.
Remove the subtraction of one.

This bug would cause INTx interrupts not to be delivered, as enabling INTB
would actually enable INTA, and enabling INTA wouldn't enable anything at
all. It is likely that this got overlooked for so long since most PCIe
hardware uses MSIs. This fixes the following UBSAN error:

  UBSAN: shift-out-of-bounds in ../drivers/pci/controller/pcie-xilinx-nwl.c:389:11
  shift exponent 18446744073709551615 is too large for 32-bit type 'int'
  CPU: 1 PID: 61 Comm: kworker/u10:1 Not tainted 6.6.20+ #268
  Hardware name: xlnx,zynqmp (DT)
  Workqueue: events_unbound deferred_probe_work_func
  Call trace:
  dump_backtrace (arch/arm64/kernel/stacktrace.c:235)
  show_stack (arch/arm64/kernel/stacktrace.c:242)
  dump_stack_lvl (lib/dump_stack.c:107)
  dump_stack (lib/dump_stack.c:114)
  __ubsan_handle_shift_out_of_bounds (lib/ubsan.c:218 lib/ubsan.c:387)
  nwl_unmask_leg_irq (drivers/pci/controller/pcie-xilinx-nwl.c:389 (discriminator 1))
  irq_enable (kernel/irq/internals.h:234 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345)
  __irq_startup (kernel/irq/internals.h:239 kernel/irq/chip.c:180 kernel/irq/chip.c:250)
  irq_startup (kernel/irq/chip.c:270)
  __setup_irq (kernel/irq/manage.c:1800)
  request_threaded_irq (kernel/irq/manage.c:2206)
  pcie_pme_probe (include/linux/interrupt.h:168 drivers/pci/pcie/pme.c:348)

Fixes: 9a181e1093 ("PCI: xilinx-nwl: Modify IRQ chip for legacy interrupts")
Link: https://lore.kernel.org/r/20240531161337.864994-3-sean.anderson@linux.dev
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-04 16:29:45 +02:00
..
controller PCI: xilinx-nwl: Fix off-by-one in INTx IRQ handler 2024-10-04 16:29:45 +02:00
endpoint PCI: endpoint: Fix error handling in epf_ntb_epc_cleanup() 2024-08-03 08:54:01 +02:00
hotplug pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv 2024-09-12 11:11:36 +02:00
msi PCI/MSI: Fix UAF in msi_capability_init 2024-07-05 09:34:01 +02:00
pcie PCI/EDR: Align EDR_PORT_LOCATE_DSM with PCI Firmware r3.3 2024-06-12 11:12:27 +02:00
switch PCI: switchtec: Fix an error handling path in switchtec_pci_probe() 2024-03-26 18:19:46 -04:00
Kconfig PCI: Fix CONFIG_PCI_DYNAMIC_OF_NODES kconfig dependencies 2023-09-05 12:42:28 -05:00
Makefile PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
access.c PCI: Simplify pcie_capability_clear_and_set_word() control flow 2023-08-25 08:16:10 -05:00
ats.c
bus.c PCI/ASPM: Fix deadlock when enabling ASPM 2024-04-27 17:11:44 +02:00
doe.c PCI/DOE: Fix destroy_work_on_stack() race 2023-07-27 15:20:47 -05:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Use pci_dev_id() to simplify the code 2023-08-07 16:15:39 -05:00
irq.c
mmap.c
of.c PCI: of: Destroy changeset when adding PCI device node fails 2023-09-29 17:33:51 -05:00
of_property.c PCI: of_property: Return error for int_map allocation failure 2024-06-12 11:12:24 +02:00
p2pdma.c PCI/P2PDMA: Fix a sleeping issue in a RCU read section 2024-03-26 18:19:46 -04:00
pci-acpi.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 17:19:57 +00:00
pci-bridge-emul.c
pci-bridge-emul.h
pci-driver.c PCI/PM: Drain runtime-idle callbacks before driver removal 2024-04-03 15:28:26 +02:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c
pci-sysfs.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 17:19:57 +00:00
pci.c PCI: Use an error code with PCIe failed link retraining 2024-10-04 16:29:45 +02:00
pci.h PCI: Use an error code with PCIe failed link retraining 2024-10-04 16:29:45 +02:00
probe.c PCI: Do error check on own line to split long "if" conditions 2023-11-28 17:19:43 +00:00
proc.c
quirks.c PCI: Use an error code with PCIe failed link retraining 2024-10-04 16:29:45 +02:00
remove.c PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
rom.c
search.c PCI: Add pci_get_base_class() helper 2024-08-11 12:47:15 +02:00
setup-bus.c PCI: Fix resource double counting on remove & rescan 2024-08-03 08:53:55 +02:00
setup-irq.c
setup-res.c PCI: Fix printk field formatting 2023-08-25 08:15:08 -05:00
slot.c
syscall.c PCI: Use consistent put_user() pointer types 2023-08-25 08:15:13 -05:00
vc.c
vgaarb.c PCI/VGA: Fix typos 2023-08-24 13:27:47 -05:00
vpd.c PCI/VPD: Add runtime power management to sysfs interface 2023-08-11 14:19:16 -05:00
xen-pcifront.c x86: always initialize xen-swiotlb when xen-pcifront is enabling 2023-07-31 17:54:27 +02:00