linux-stable/drivers/pci
Krzysztof Wilczyński 35f3da7e74 PCI: Return ~0 data on pciconfig_read() CAP_SYS_ADMIN failure
commit a8bd29bd49 upstream.

The pciconfig_read() syscall reads PCI configuration space using
hardware-dependent config accessors.

If the read fails on PCI, most accessors don't return an error; they
pretend the read was successful and got ~0 data from the device, so the
syscall returns success with ~0 data in the buffer.

When the accessor does return an error, pciconfig_read() normally fills the
user's buffer with ~0 and returns an error in errno.  But after
e4585da22a ("pci syscall.c: Switch to refcounting API"), we don't fill
the buffer with ~0 for the EPERM "user lacks CAP_SYS_ADMIN" error.

Userspace may rely on the ~0 data to detect errors, but after e4585da22a,
that would not detect CAP_SYS_ADMIN errors.

Restore the original behaviour of filling the buffer with ~0 when the
CAP_SYS_ADMIN check fails.

[bhelgaas: commit log, fold in Nathan's fix
https://lore.kernel.org/r/20210803200836.500658-1-nathan@kernel.org]
Fixes: e4585da22a ("pci syscall.c: Switch to refcounting API")
Link: https://lore.kernel.org/r/20210729233755.1509616-1-kw@linux.com
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-22 11:45:25 +02:00
..
dwc PCI: qcom: Add missing reset for ipq806x 2020-12-29 13:46:44 +01:00
endpoint PCI: endpoint: Fix for concurrent memory allocation in OB address region 2020-04-24 08:00:37 +02:00
host PCI: aardvark: Fix kernel panic during PIO transfer 2021-07-20 16:17:48 +02:00
hotplug ACPI / hotplug / PCI: Fix reference count leak in enable_slot() 2021-05-22 10:57:42 +02:00
pcie PCI/ASPM: Add missing newline in sysfs 'policy' 2020-08-21 09:48:10 +02:00
switch PCI/switchtec: Fix init_completion race condition with poll_wait() 2020-04-24 08:00:27 +02:00
access.c PCI: Fix pci_cfg_wait queue locking problem 2020-08-21 09:48:09 +02:00
ats.c
bus.c PCI: Add device even if driver attach failed 2020-12-02 08:34:39 +01:00
ecam.c
host-bridge.c
hotplug-pci.c
htirq.c
iov.c PCI/IOV: Fix memory leak in pci_iov_add_virtfn() 2020-02-28 16:35:59 +01:00
irq.c
Kconfig
Makefile
mmap.c
msi.c PCI/MSI: Skip masking MSI-X on Xen PV 2021-09-22 11:45:24 +02:00
of.c
pci-acpi.c PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() 2020-12-29 13:47:04 +01:00
pci-driver.c PCI/PM: Always return devices to D0 when thawing 2019-12-21 10:47:40 +01:00
pci-label.c PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun 2021-07-20 16:17:53 +02:00
pci-mid.c
pci-stub.c
pci-sysfs.c
pci.c PCI: PM: Enable PME if it can be signaled from D3cold 2021-09-22 11:45:20 +02:00
pci.h PCI: thunder: Fix compile testing 2021-05-22 10:57:42 +02:00
probe.c PCI: Release OF node in pci_scan_device()'s error path 2021-05-22 10:57:38 +02:00
proc.c
quirks.c PCI: Restrict ASMedia ASM1062 SATA Max Payload Size Supported 2021-09-22 11:45:25 +02:00
remove.c
rom.c
search.c
setup-bus.c PCI: Don't disable bridge BARs when assigning bus resources 2020-02-14 16:32:21 -05:00
setup-irq.c
setup-res.c
slot.c PCI: Fix pci_slot_release() NULL pointer dereference 2020-12-29 13:47:11 +01:00
syscall.c PCI: Return ~0 data on pciconfig_read() CAP_SYS_ADMIN failure 2021-09-22 11:45:25 +02:00
vc.c
vpd.c
xen-pcifront.c