linux/drivers/pci
Valentine Sinitsyn 24de09c16f PCI: Implement custom llseek for sysfs resource entries
Since commit 636b21b501 ("PCI: Revoke mappings like devmem"), mmappable
sysfs entries have started to receive their f_mapping from the iomem
pseudo filesystem, so that CONFIG_IO_STRICT_DEVMEM is honored in sysfs
(and procfs) as well as in /dev/[k]mem.

This resulted in a userspace-visible regression:

1. Open a sysfs PCI resource file (eg. /sys/bus/pci/devices/*/resource0)
2. Use lseek(fd, 0, SEEK_END) to determine its size

Expected result: a PCI region size is returned.
Actual result: 0 is returned.

The reason is that PCI resource files residing in sysfs use
generic_file_llseek(), which relies on f_mapping->host inode to get the
file size. As f_mapping is now redefined, f_mapping->host points to an
anonymous zero-sized iomem_inode which has nothing to do with sysfs file
in question.

Implement a custom llseek method for sysfs PCI resources, which is
almost the same as proc_bus_pci_lseek() used for procfs entries.

This makes sysfs and procfs entries consistent with regards to seeking,
but also introduces userspace-visible changes to seeking PCI resources
in sysfs:

- SEEK_DATA and SEEK_HOLE are no longer supported;
- Seeking past the end of the file is prohibited while previously
  offsets up to MAX_NON_LFS were accepted (reading from these offsets
  was always invalid).

Signed-off-by: Valentine Sinitsyn <valesini@yandex-team.ru>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20230925084013.309399-2-valesini@yandex-team.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-05 13:42:15 +02:00
..
controller pci-v6.6-changes 2023-08-30 20:23:07 -07:00
endpoint Merge branch 'pci/misc' 2023-08-29 11:03:57 -05:00
hotplug powerpc updates for 6.6 2023-08-31 12:43:10 -07:00
msi PCI: Fix typos in docs and comments 2023-08-25 08:15:38 -05:00
pcie PCI/AER: Export pcie_aer_is_native() 2023-09-11 15:24:16 -07:00
switch PCI: switchtec: Add support for PCIe Gen5 devices 2023-08-09 14:16:44 -05:00
access.c PCI: Simplify pcie_capability_clear_and_set_word() control flow 2023-08-25 08:16:10 -05:00
ats.c PCI: Enable PASID only when ACS RR & UF enabled on upstream path 2022-11-03 15:47:47 +01:00
bus.c Devicetree updates for v6.6: 2023-08-30 16:59:03 -07:00
doe.c PCI/DOE: Fix destroy_work_on_stack() race 2023-07-27 15:20:47 -05:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Use pci_dev_id() to simplify the code 2023-08-07 16:15:39 -05:00
irq.c PCI: Check for alloc failure in pci_request_irq() 2022-11-21 16:55:18 -06:00
Kconfig PCI: Fix CONFIG_PCI_DYNAMIC_OF_NODES kconfig dependencies 2023-09-05 12:42:28 -05:00
Makefile PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
mmap.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
of_property.c PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
of.c Devicetree updates for v6.6: 2023-08-30 16:59:03 -07:00
p2pdma.c PCI: Fix typos in docs and comments 2023-08-25 08:15:38 -05:00
pci-acpi.c PCI/ACPI: Call _REG when transitioning D-states 2023-06-23 12:28:08 -05:00
pci-bridge-emul.c PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-08-25 12:07:56 +02:00
pci-bridge-emul.h PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-08-25 12:07:56 +02:00
pci-driver.c PCI: Simplify pci_dev_driver() 2023-08-25 08:15:29 -05:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c PCI: pci_stub: Set driver_managed_dma 2022-04-28 15:32:20 +02:00
pci-sysfs.c PCI: Implement custom llseek for sysfs resource entries 2023-10-05 13:42:15 +02:00
pci.c Merge branch 'pci/misc' 2023-08-29 11:03:57 -05:00
pci.h pci-v6.6-changes 2023-08-30 20:23:07 -07:00
probe.c PCI: Free released resource after coalescing 2023-09-06 12:19:29 -05:00
proc.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
quirks.c Revert "PCI: Mark NVIDIA T4 GPUs to avoid bus reset" 2023-09-08 15:11:45 -05:00
remove.c PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
rom.c
search.c
setup-bus.c PCI: Fix typos in docs and comments 2023-08-25 08:15:38 -05:00
setup-irq.c
setup-res.c PCI: Fix printk field formatting 2023-08-25 08:15:08 -05:00
slot.c PCI/sysfs: Constify struct kobj_type pci_slot_ktype 2023-02-16 12:00:25 -06:00
syscall.c PCI: Use consistent put_user() pointer types 2023-08-25 08:15:13 -05:00
vc.c
vgaarb.c PCI/VGA: Fix typos 2023-08-24 13:27:47 -05:00
vpd.c PCI/VPD: Add runtime power management to sysfs interface 2023-08-11 14:19:16 -05:00
xen-pcifront.c x86: always initialize xen-swiotlb when xen-pcifront is enabling 2023-07-31 17:54:27 +02:00