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 A7535FA1FC7 for ; Wed, 22 Apr 2026 16:15:45 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4g147L0J5Gz2yv6; Thu, 23 Apr 2026 02:14:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c04:e001:324:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776874493; cv=none; b=DTyjQjPfony2Mis14Vyg0oXQvIdGqqhI1t04LTtMWvng3TNZa086nVWcziHr6xri0a48EILXlWiz5tAzbhvJBS3pJFsGSrpNaXsuAsUYFQrjUODCFUEOv9vtSKMxQctLVtW0UMCVcTTdYyj/oIgnfrezy0liyX//nAUsjLeqNPuwgn4MUx7ouaYilqP6WTfwFoRlHB0FsiWo+wzkO+uxkloS4legHg0jUfa0Goh4BadqrxwAIhOrOVghP3WgQDOupNnergZRtCs7rdClmmowJLO+pdgcidIHLQjXP7cf8z79zZzs6VPTeDVjNa4613U2Zf2tt7ZNFqJ4ft8s9goL8A== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776874493; c=relaxed/relaxed; bh=8hynRy6TmK58aWbYnFQGqModmwP+3PNQbC7o/HJkS9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e8Fe10hHqKgW1Q/aYIxifUtKzixZiaxJoj2ARrt03x3iY6MfxlUtbHGA5aguA0QIvUidvSUeA+HBZkSvJpCnsIx+cjPhh0I5K8idl9AiL1etHRlzH4Cp5b0VJhmkhEN0USuiuF7OMXD2ZQeAAhHLjVIq/pLphzxkQFgoGRi7XYCAusiNg+NwofvOUCFRdzZNEH93+KHPuNgNLJ0NacALTYcozBANfwxvq97QEf3jN7AUbfArmwIv3/Fej/+rfn96jMU7ZEhhCK57PDi5jaIw86lBRUntqhNBJcviyjEAQFEACRpfBdrfhlmJ5xUPp5K+WU0+C/aguya2Xk0O8N98pg== 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=GhKrrLTT; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.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=GhKrrLTT; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) (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 4g147J41rqz2yr9 for ; Thu, 23 Apr 2026 02:14:52 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 7A3E36012A; Wed, 22 Apr 2026 16:14:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10EDAC2BCAF; Wed, 22 Apr 2026 16:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776874490; bh=G9J13TW73xutdYdnp+hqNnYui77KfP+Wzlkm8iI4IbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhKrrLTTQzUJd8oryNF9cvyIUBhElsLD4y/1HGPKupzEibiJ5WObIQimuKDXqgUdE hiZE/Nmbt9b5ligXi1K0HzJlcrclXWh2v9xIYCvtR1Qc2G0hvky1RG06yjEN/Kd2VA uuQOV2f7fNJE9ysHJyOsYSejRC5SdRa6BNOew0+8iodDX52QTTSrtQZ7wYSfhU5gpU 7owy4FcH4+VGzkbBVsLMkLaCPnH1vvxf4fqzZaueYwS2FTYFJ85C3bJe/b3N+AYC0h aD9ImRlkz6ojbok6thc3YuoguRrChzW/5HrJX9wGEy+XGuJ+QHSjBhahQ9mzV3A2Em 5+S4vv/DvRv4g== 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 v6 11/24] alpha/PCI: Add security_locked_down() check to pci_mmap_resource() Date: Wed, 22 Apr 2026 16:13:54 +0000 Message-ID: <20260422161407.118748-12-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260422161407.118748-1-kwilczynski@kernel.org> References: <20260422161407.118748-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 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