From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 682D618FDBD; Fri, 19 Jun 2026 08:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781859166; cv=none; b=VaxOiwYEHckMOzpJWpkzyDFMqDHFT7XhLd5NdFtUEtVDKGjwkeI7T6cK5I6KF7xCSoxTRZj9d5yKI3+vMTJDw+/HWdB4lnJc4bEuTT8fP3rELK+70xfdXQ9uwqZiCLaY6TpW+LAdigaKm3T67ikmWrO/vYxzty+1av+HwyQw42Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781859166; c=relaxed/simple; bh=E3tfvAE5/RgXcJHgVGPP0ui+GO/m1px+JjWaS1Ub+oM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=efuNSdLUklCSv+uGe1BrxXShmySjZ6tfbzILex4O9Omfv1lHCWihJOFLM1f+8zm6/cXM1bEXw9K3+sucgp0o73EQNg8ACH0+8oSvg0G+4EY/TJJqzGmnn+UJUGb/E0vUDKcmR5UkUUXjsgE8n+y9ciMV/WatXYBfz1ChFUL8vmk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BXpDljBG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BXpDljBG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEA9F1F00A3A; Fri, 19 Jun 2026 08:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781859165; bh=pMuVQQr2pWe9V9DOF5+KI8VOApNtmpAfW/aKio6l7sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BXpDljBGNZeba421cMa3DpdGQLCzdvMElFNkXNEMLYam7fvP9xHJTCk1VvxhMyQQs kIauTb9QjedYsJW1pXTlYf1vWQ8y0fzFoTvi4xFG6GOqbh6gz9KpxLOMh3AY7qboQz CyOWIIMqcSnxHTcPBnoON07cKdHnzCRDIhrcjCFVkB8mwX9HrA5T5Vt2eBG7AD1tSS 6g4HDxkQaglP7krBlk1zN0RNi5iW6Q/9K1b+gfA5+uAQaZaAIf6LFklO8G8pr6kR6O NNjR2zQa9xeYOzyO+eRlOX636zSN4vjre1o6nyvrvxjw2fsVwXbddLAW/h/1OYVJ7Q 08QdsqhvJYtsA== From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , Alex Williamson , Magnus Lindholm , Matt Turner , Richard Henderson , Christophe Leroy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Dexuan Cui , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , Lukas Wunner , "Oliver O'Halloran" , Saurabh Singh Sengar , Shuan He , Srivatsa Bhat , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v8 11/25] alpha/PCI: Add security_locked_down() check to pci_mmap_resource() Date: Fri, 19 Jun 2026 08:51:46 +0000 Message-ID: <20260619085200.3729431-12-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260619085200.3729431-1-kwilczynski@kernel.org> References: <20260619085200.3729431-1-kwilczynski@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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") Tested-by: Magnus Lindholm Tested-by: Shivaprasad G Bhat Reviewed-by: Ilpo Järvinen Acked-by: Magnus Lindholm Signed-off-by: Krzysztof Wilczyński --- arch/alpha/kernel/pci-sysfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c index 3048758304b5..2324720c3e83 100644 --- a/arch/alpha/kernel/pci-sysfs.c +++ b/arch/alpha/kernel/pci-sysfs.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -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]) -- 2.54.0