From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48887CD3436 for ; Fri, 8 May 2026 04:37:20 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gBbt7030Mz30PJ; Fri, 08 May 2026 14:36:31 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.234.252.31 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778214990; cv=none; b=gWKyCPJXi0CGx9UKNOeyUoKEH4PrwxBZdZcNh/Ujm0x1vZaEN61xUF/JvM9JpI/pXv66tEVKeOiWoGrKZadlGJj1TSmS0MU+s9lhh+M90Ynh6lj53lxcogF86HMayOP7VaQX+QnQuhi8fHBh2IZo+wvqdMQGMgODw9x5D7Tv3ms5YyRs6ZDLxKQWXHLkB/v3YaR6lVrxhpH+w+2erekw5/1RxuN3s6UguRizzCLIuvRYGA3zESMNL2mhe6YXN0EIavo6McjKdSVE0VWsZFln8N81/5nJxaingvA+DDqg4xk5BkI3KiU7rn1cvy7xHEONAunG1i83KEKg+1kXSpt5BQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778214990; c=relaxed/relaxed; bh=pMuVQQr2pWe9V9DOF5+KI8VOApNtmpAfW/aKio6l7sQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CyLqzeTBoNBRNqquzewF1ILCnJhAoQgXxazehwIV6mO4YCjPsfHyLG8/1CdJWe312qycy7BUUdz57OA9uirYJkJIJdE7gm+8GXf2LN0so6bZT7C+/m2BN+eMvtBCXLSiuq4HpbI8wPPxfGv9eV1K9t3J+8BWhOjrLyem8L/7cT12cFDIpAEz/zGO+LxQHxjKm7MqiZflUM6xlyh7esy3IfEbcHJpgza/NEKsMXMJmTU9ofdbbGVWOBoJB1AJfItgrzWXiYbSFECwYmY0OVY8obqjDxlbK9fJEHEeVZgByMjDTTscLZH7FZ4WCYMXAz1kIivB6O+tXKfcMrICpWymdA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=tsZKrBGP; dkim-atps=neutral; spf=pass (client-ip=172.234.252.31; helo=sea.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=tsZKrBGP; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.234.252.31; helo=sea.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4gBbt63Bv7z2xPb for ; Fri, 08 May 2026 14:36:30 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id E99F543EB4; Fri, 8 May 2026 04:36:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86E14C2BCC9; Fri, 8 May 2026 04:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778214988; bh=E3tfvAE5/RgXcJHgVGPP0ui+GO/m1px+JjWaS1Ub+oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsZKrBGP7bNsWsDkwaURkp4PmWvykFdBnPF/PqBsgzZgbyTS8vuc28ZDlJuojQRlp +/HZg/NJY7tqhKCHwjDvx2e8LueiXxIyy8ZZ/lfUUpf0WgDrLCcuQ5SipcQoWxNxl3 bhn6GIa62P2xae/2ID5B31jIn/Uy2UP0iR8yQd8YgtzFDHKyaQPtXrvedce/bUGAr0 oQKjUfn/mMuPVawuiTNmZTcp685q9Hkw0Vt7DfjgUsdVMEVj3LM7BKlilwMBknrOhv HCeNvJm1QIuyNyn44giFkBRgrqJpJQ//Yu7WLcEy7doctbCPPyhTExtD/PrstjotZx nvRAN0sUR5K/A== 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 v7 11/24] alpha/PCI: Add security_locked_down() check to pci_mmap_resource() Date: Fri, 8 May 2026 04:35:30 +0000 Message-ID: <20260508043543.217179-12-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260508043543.217179-1-kwilczynski@kernel.org> References: <20260508043543.217179-1-kwilczynski@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list 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