From e67cac124ca7a2768523efb986d9d6966a2091d1 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Wed, 10 Mar 2021 09:47:31 -0600 Subject: [PATCH 1/2] MAINTAINERS: Update PCI patchwork to kernel.org instance We now use the kernel.org patchwork instance. Update the links in MAINTAINERS. Signed-off-by: Bjorn Helgaas --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index d92f85ca831d..a3c2e930b3d5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13843,7 +13843,7 @@ M: Lorenzo Pieralisi R: Rob Herring L: linux-pci@vger.kernel.org S: Supported -Q: http://patchwork.ozlabs.org/project/linux-pci/list/ +Q: http://patchwork.kernel.org/project/linux-pci/list/ T: git git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/ F: drivers/pci/controller/ @@ -13851,7 +13851,7 @@ PCI SUBSYSTEM M: Bjorn Helgaas L: linux-pci@vger.kernel.org S: Supported -Q: http://patchwork.ozlabs.org/project/linux-pci/list/ +Q: http://patchwork.kernel.org/project/linux-pci/list/ T: git git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git F: Documentation/PCI/ F: Documentation/devicetree/bindings/pci/ From cf673bd0cc973b25961d41355990beaed710068f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= Date: Sat, 20 Feb 2021 06:28:37 +0000 Subject: [PATCH 2/2] PCI: switchtec: Fix Spectre v1 vulnerability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "partition" member of the struct switchtec_ioctl_pff_port can be indirectly controlled from user-space through an IOCTL that the device driver provides enabling conversion between a PCI Function Framework (PFF) number and Switchtec logical port ID and partition number, thus allowing for command-line tooling [1] interact with the device from user-space. This can lead to potential exploitation of the Spectre variant 1 [2] vulnerability since the value of the partition is then used directly as an index to mmio_part_cfg_all[] of the struct switchtec_dev to retrieve configuration from Switchtec for a specific partition number. Fix this by sanitizing the value coming from user-space through the available IOCTL before it's then used as an index to mmio_part_cfg_all[]. This issue was detected with the help of Smatch: drivers/pci/switch/switchtec.c:1118 ioctl_port_to_pff() warn: potential spectre issue 'stdev->mmio_part_cfg_all' [r] (local cap) Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [3]. Related commit 46feb6b495f7 ("switchtec: Fix Spectre v1 vulnerability"). [1] https://github.com/Microsemi/switchtec-user/blob/master/lib/platform/linux.c [2] https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/spectre.html [3] https://lore.kernel.org/lkml/CAPcyv4gLKYiCtXsKFX2FY+rW93aRtQt9zB8hU1hMsj770m8gxQ@mail.gmail.com/ Link: https://lore.kernel.org/r/20210220062837.1683159-1-kw@linux.com Signed-off-by: Krzysztof WilczyƄski Signed-off-by: Bjorn Helgaas Reviewed-by: Logan Gunthorpe --- drivers/pci/switch/switchtec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index ba52459928f7..bb6957101fc0 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -1112,12 +1112,15 @@ static int ioctl_port_to_pff(struct switchtec_dev *stdev, if (copy_from_user(&p, up, sizeof(p))) return -EFAULT; - if (p.partition == SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX) + if (p.partition == SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX) { pcfg = stdev->mmio_part_cfg; - else if (p.partition < stdev->partition_count) + } else if (p.partition < stdev->partition_count) { + p.partition = array_index_nospec(p.partition, + stdev->partition_count); pcfg = &stdev->mmio_part_cfg_all[p.partition]; - else + } else { return -EINVAL; + } switch (p.port) { case 0: