From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 139941514F8; Thu, 16 Apr 2026 18:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776362511; cv=none; b=dOxDcNCBUu1Nitvtsihfl02fzRPmPe1b3m913OnEMy9RuCApaYscNooEBCGaFFQYJMFJ5+pHscZq3/rR95saLtOPpU1VEyFLbIN4Og5M4dPIP1cQb/63OAqsw99k8qEuju48BkAh2PpvSsDt8wMtTzAnjaM9ycwyXztxQZeYQYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776362511; c=relaxed/simple; bh=ynGnSMSFqOAAKmLZRmEyMAZNgYryMwxIuUv1xLlXFbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KU+Awr81BNddTj6isSnva2vUNMmzCWGRwTxCyxiFdp9Ex1sRZ0X4ih3SXql+ozXXKjT5TE35+2tqWWoIB6C57Jku8eBdl6VzBO3Wl2nnVDKVXM8xGeNnCloD+SUeNxfSMsRy4LmRXVVaMp1Ygg0HwcsWFfWGjY8oziMNLNBFmP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vRS/mQhV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vRS/mQhV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A12AC2BCAF; Thu, 16 Apr 2026 18:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776362510; bh=ynGnSMSFqOAAKmLZRmEyMAZNgYryMwxIuUv1xLlXFbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vRS/mQhVt4v6pbbwRuRp+3xi/wnp2uYmhsRaYhN4EMQyiIPjz7f1U8eTl4xhkqjt8 KlF2dtVGTSMrztvuWx0t2NhJD1N+THTMSRMwESPQTtgxODKTWrX9qkhuagqpgZRfoW mwXSliJWA6X0ArMLDMA5p0wCcCMaD9AAbOcf6VTtJeGoK+ZqgKVW3zsRzn0Y3Y4WzF DePodAHWOLMKDqCW/IiMI8SyvahzGh0dDt53HjVpwwPjTar4AGqmXLEXJBacNyvymd pppmWG9/19Earg7BHtBunVuN50FU/lXGZs2wXdyTbtWC6FFDhXoVWJu2QaXheZXKZZ 2YVPFFVbfCD/Q== From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , 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 v5 11/23] alpha/PCI: Add security_locked_down() check to pci_mmap_resource() Date: Thu, 16 Apr 2026 18:00:55 +0000 Message-ID: <20260416180107.777065-12-kwilczynski@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416180107.777065-1-kwilczynski@kernel.org> References: <20260416180107.777065-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 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.53.0