mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/pci: prevent cross-device accesses in pci_mmcfg_{read,write}()
Introduce a specific check that prevents an accesses from spilling across
two devices.
Signed-off-by: Roger Pau Monné <roger@xenproject.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
master commit: 6acdfad3da
master date: 2026-08-26 11:50:42 +0200
This commit is contained in:
1 parent
314bdc9be4
commit
9ee0c50a0e
1 file changed
+4
-2
@@ -61,7 +61,8 @@ int pci_mmcfg_read(unsigned int seg, unsigned int bus,
|
||||
char __iomem *addr;
|
||||
|
||||
/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
|
||||
if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) {
|
||||
if (unlikely((bus > 255) || (devfn > 255) ||
|
||||
(reg + len > PCI_CFG_SPACE_EXP_SIZE))) {
|
||||
err: *value = -1;
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -91,7 +92,8 @@ int pci_mmcfg_write(unsigned int seg, unsigned int bus,
|
||||
char __iomem *addr;
|
||||
|
||||
/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
|
||||
if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095)))
|
||||
if (unlikely((bus > 255) || (devfn > 255) ||
|
||||
(reg + len > PCI_CFG_SPACE_EXP_SIZE)))
|
||||
return -EINVAL;
|
||||
|
||||
addr = pci_dev_base(seg, bus, devfn);
|
||||
|
||||