Skip to content

Commit 4de5ff9

Browse files
kwilczynskigregkh
authored andcommitted
alpha/PCI: Add security_locked_down() check to pci_mmap_resource()
[ Upstream commit 78a228f ] 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 eb627e1 ("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: eb627e1 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4e5ed2a commit 4de5ff9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

arch/alpha/kernel/pci-sysfs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include <linux/sched.h>
14+
#include <linux/security.h>
1415
#include <linux/stat.h>
1516
#include <linux/slab.h>
1617
#include <linux/pci.h>
@@ -71,7 +72,11 @@ static int pci_mmap_resource(struct kobject *kobj,
7172
struct resource *res = attr->private;
7273
enum pci_mmap_state mmap_type;
7374
struct pci_bus_region bar;
74-
int i;
75+
int i, ret;
76+
77+
ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
78+
if (ret)
79+
return ret;
7580

7681
for (i = 0; i < PCI_STD_NUM_BARS; i++)
7782
if (res == &pdev->resource[i])

0 commit comments

Comments
 (0)