From: Xiongfeng Wang xiongfeng.wang@linaro.org
euler inclusion category: bugfix bugzilla: 4390,https://gitee.com/openeuler/kernel/issues/I4OG3O?from=project-issue CVE: NA
----------------------------------------
This patch add check for the offset of MSI-X Table. If it is out of range of the BAR space BIR selects, we just fail this MSI-X mapping.
Signed-off-by: Xiongfeng Wang xiongfeng.wang@linaro.org Reviewed-by: Hanjun Guo guohanjun@huawei.com Signed-off-by: Mao Wenan maowenan@huawei.com Signed-off-by: Hui Wang john.wanghui@huawei.com
Signed-off-by: Zhang Xiaoxu zhangxiaoxu5@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Jialin Zhang zhangjialin11@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- drivers/pci/msi.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index db7475dc601f..294b16cde9e7 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -711,6 +711,12 @@ static void __iomem *msix_map_region(struct pci_dev *dev, unsigned nr_entries) return NULL;
table_offset &= PCI_MSIX_TABLE_OFFSET; + if (table_offset >= pci_resource_len(dev, bir)) { + dev_err(&dev->dev, + "MSI-X Table offset is out of range of BAR:%d!\n", + bir); + return NULL; + } phys_addr = pci_resource_start(dev, bir) + table_offset;
return ioremap(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);