Re: [PATCH] PCI/sysfs: Add lockdown checks to legacy I/O and memory handlers

Krzysztof WilczyƄski <[email protected]> Sat, 1 Aug 2026 13:09:17 +0900
Newsgroups org.kernel.vger.linux-pci
Message-ID <20260801040854.GG3183355@rocinante>
Hello,

> Currently, the legacy I/O and memory sysfs handlers do not
> check security_locked_down(LOCKDOWN_PCI_ACCESS), leaving the
> legacy_io and legacy_mem files unprotected when the kernel is
> locked down.
> 
> Commit eb627e17727e ("PCI: Lock down BAR access when the
> kernel is locked down") added the check to pci_write_config(),
> pci_mmap_resource(), and pci_write_resource_io() to prevent
> userspace from programming DMA-capable hardware that could be
> used to modify kernel code, but did not cover the legacy
> handlers.
> 
> As a result, root can still write arbitrary I/O ports and map
> the legacy I/O and memory spaces while the kernel is locked
> down, which is the same capability the lockdown is meant to
> remove.
> 
> Thus, add the same check to pci_write_legacy_io(),
> pci_mmap_legacy_mem(), and pci_mmap_legacy_io().
> 
> These generic handlers cover both architectures that
> define HAVE_PCI_LEGACY (such as Alpha and PowerPC).

Applied to the sysfs branch.

Thank you!

	Krzysztof