]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
alpha/PCI: Add security_locked_down() check to pci_mmap_resource()
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:30 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 20:19:08 +0000 (15:19 -0500)
Currently, Alpha's pci_mmap_resource() does not check
security_locked_down(LOCKDOWN_PCI_ACCESS) before allowing userspace to mmap
PCI BARs.

The generic version has had this check since commit eb627e17727e ("PCI:
Lock down BAR access when the kernel is locked down") to prevent DMA
attacks when the kernel is locked down.

Add the same check to Alpha's pci_mmap_resource().

Fixes: eb627e17727e ("PCI: Lock down BAR access when the kernel is locked down")
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Link: https://patch.msgid.link/20260508043543.217179-12-kwilczynski@kernel.org
arch/alpha/kernel/pci-sysfs.c

index 3048758304b57afa01ddeb6558c39bdb48c9a3f6..2324720c3e83fb11c6795575fd4830211ce2c3f5 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/security.h>
 #include <linux/stat.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
@@ -71,7 +72,11 @@ static int pci_mmap_resource(struct kobject *kobj,
        struct resource *res = attr->private;
        enum pci_mmap_state mmap_type;
        struct pci_bus_region bar;
-       int i;
+       int i, ret;
+
+       ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
+       if (ret)
+               return ret;
 
        for (i = 0; i < PCI_STD_NUM_BARS; i++)
                if (res == &pdev->resource[i])