Re: [PATCH 10/20] alpha/PCI: Add security_locked_down() check to pci_mmap_resource()

Ilpo Järvinen <[email protected]>
Newsgroups org.kernel.vger.linux-alpha,org.kernel.vger.linux-pci,org.ozlabs.lists.linuxppc-dev
Message-ID <[email protected]>
On Fri, 10 Apr 2026, Krzysztof Wilczyński wrote:

> 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().
> 
> Signed-off-by: Krzysztof Wilczyński <[email protected]>

Maybe add Fixes: eb627e17727e ...

> ---
>  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 <linux/sched.h>
> +#include <linux/security.h>
>  #include <linux/stat.h>
>  #include <linux/slab.h>
>  #include <linux/pci.h>
> @@ -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])
> 

Reviewed-by: Ilpo Järvinen <[email protected]>

-- 
 i.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.