linux/drivers/pci
Balbir Singh 7ffb791423 x86/kaslr: Reduce KASLR entropy on most x86 systems
When CONFIG_PCI_P2PDMA=y (which is basically enabled on all
large x86 distros), it maps the PFN's via a ZONE_DEVICE
mapping using devm_memremap_pages(). The mapped virtual
address range corresponds to the pci_resource_start()
of the BAR address and size corresponding to the BAR length.

When KASLR is enabled, the direct map range of the kernel is
reduced to the size of physical memory plus additional padding.
If the BAR address is beyond this limit, PCI peer to peer DMA
mappings fail.

Fix this by not shrinking the size of the direct map when
CONFIG_PCI_P2PDMA=y.

This reduces the total available entropy, but it's better than
the current work around of having to disable KASLR completely.

[ mingo: Clarified the changelog to point out the broad impact ... ]

Signed-off-by: Balbir Singh <balbirs@nvidia.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/Kconfig
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Link: https://lore.kernel.org/lkml/20250206023201.1481957-1-balbirs@nvidia.com/
Link: https://lore.kernel.org/r/20250206234234.1912585-1-balbirs@nvidia.com
--
 arch/x86/mm/kaslr.c | 10 ++++++++--
 drivers/pci/Kconfig |  6 ++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
2025-02-22 12:25:57 +01:00
..
controller pci-v6.14-changes 2025-01-25 16:03:40 -08:00
endpoint Merge branch 'pci/endpoint-test' 2025-01-23 13:04:53 -06:00
hotplug PCI/ACPI: Constify 'struct bin_attribute' 2024-12-10 13:00:50 -06:00
msi PCI: Remove devres from pci_intx() 2025-01-18 14:38:49 -06:00
pcie PCI/ASPM: Fix L1SS saving 2025-02-06 09:54:38 -06:00
pwrctrl pci-v6.13-changes 2024-11-26 18:05:44 -08:00
switch PCI: switchtec: Add Microchip PCI100X device IDs 2025-01-21 10:47:28 -06:00
access.c PCI: Revert the cfg_access_lock lockdep mechanism 2024-06-04 12:10:05 -05:00
ats.c PCI: Store number of supported End-End TLP Prefixes 2025-01-14 17:47:39 -06:00
bus.c Merge branch 'pci/pwrctl' 2024-11-25 13:40:54 -06:00
devres.c PCI: Restore original INTX_DISABLE bit by pcim_intx() 2025-01-27 12:55:12 -06:00
doe.c PCI/DOE: Poll DOE Busy bit for up to 1 second in pci_doe_send_req() 2024-10-13 10:55:39 -05:00
ecam.c PCI: Use resource_set_{range,size}() helpers 2024-10-10 17:44:57 -05:00
host-bridge.c
iomap.c PCI: Fix typos 2024-09-19 14:24:00 -05:00
iov.c PCI: Batch BAR sizing operations 2025-01-23 11:05:20 -06:00
irq.c PCI: Place interrupt related code into irq.c 2024-01-29 17:01:31 -06:00
Kconfig x86/kaslr: Reduce KASLR entropy on most x86 systems 2025-02-22 12:25:57 +01:00
Makefile Merge branch 'pci/tph' 2024-11-25 13:40:55 -06:00
mmap.c PCI/sysfs: Compile pci-sysfs.c only if CONFIG_SYSFS=y 2024-03-05 16:08:43 -06:00
npem.c PCI/NPEM: Add _DSM PCIe SSD status LED management 2024-09-06 11:37:24 -05:00
of_property.c PCI: of_property: Rename struct of_pci_range to of_pci_range_entry 2025-01-18 15:18:38 -06:00
of.c PCI: of: Simplify devm_of_pci_get_host_bridge_resources() interface 2025-01-15 15:26:51 -06:00
p2pdma.c PCI/P2PDMA: Constify 'struct bin_attribute' 2024-12-03 15:29:59 -06:00
pci-acpi.c ACPI: RISC-V: Implement PCI related functionality 2024-08-27 15:48:35 +02:00
pci-bridge-emul.c PCI: Rename CRS Completion Status to RRS 2024-09-10 19:52:30 -05:00
pci-bridge-emul.h
pci-driver.c PCI: hookup irq_get_affinity callback 2024-12-23 08:17:23 -07:00
pci-label.c
pci-mid.c PCI/PM: Switch to new Intel CPU model defines 2024-06-11 17:08:14 -05:00
pci-pf-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-sysfs.c Merge branch 'pci/misc' 2025-01-23 13:05:06 -06:00
pci.c pci-v6.14-changes 2025-01-25 16:03:40 -08:00
pci.h Merge branch 'pci/pci-sysfs' 2025-01-23 13:04:51 -06:00
probe.c PCI: Fix BUILD_BUG_ON usage for old gcc 2025-02-12 16:16:21 -06:00
proc.c
quirks.c PCI: Avoid FLR for Mediatek MT7922 WiFi 2025-02-13 08:36:54 -06:00
remove.c PCI/pwrctrl: Unregister platform device only if one actually exists 2024-11-30 11:41:25 -06:00
rom.c
search.c PCI: Add pci_get_base_class() helper 2023-09-28 16:49:44 -05:00
setup-bus.c PCI: Improve pdev_sort_resources() warning message 2024-10-18 18:41:11 -05:00
setup-res.c PCI: Use resource_set_{range,size}() helpers 2024-10-10 17:44:57 -05:00
slot.c Merge branch 'pci/misc' 2024-11-25 13:41:00 -06:00
syscall.c
tph.c PCI/TPH: Restore TPH Requester Enable correctly 2025-02-06 10:30:11 -06:00
vc.c PCI/VC: Use FIELD_GET() 2023-10-24 16:55:45 -05:00
vgaarb.c pci-v6.7-changes 2023-11-02 14:05:18 -10:00
vpd.c PCI/VPD: Constify 'struct bin_attribute' 2024-12-03 15:25:41 -06:00
xen-pcifront.c