Skip to contentSkip to conversation

s390/pci: Fix s390_pci_mmio_write syscall error return without MIO

PATCH Applied Niklas Schnelle 3 participants 3 messages Jul 22 – Jul 23

Subsystems (2)
lore
Share & tools
lore

Niklas Schnelle

author maintainer
#0 lore raw

PATCH 1/1 s390/pci: Fix s390_pci_mmio_write syscall error return without MIO

On a machine without PCI memory-I/O (MIO) support or when running with pci=nomio the s390 specific PCI MMIO write syscall checks if the MMIO cookie is above ZPCI_IOMAP_ADDR_BASE as a sanity check before even trying to perform the MMIO. If this check fails the return value was left unchanged and thus 0 from prior operations falsely indicating success. This could potentially confuse user-space into falsely believing the MMIO, on a mapping not valid for MMIO was successful.

Fix this by setting the return value to -EFAULT prior to the check following the same pattern as elsewhere in the same function.

Fixes a67a88b0b8de ("s390/pci: remove races against pte updates")
---
 arch/s390/pci/pci_mmio.c | 1 +
 1 file changed, 1 insertion(+)
arch/s390/pci/pci_mmio.c +1 -0
index 51e7a28af899..f3f79ba78410 100644
@@ -188,6 +188,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
 			goto out_unlock_mmap;
 	}
 
+	ret = -EFAULT;
 	io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) |
 			(mmio_addr & ~PAGE_MASK));
 

---
base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
change-id: 20260721-b4-syscall_mmio_ret_fix_upstream-ec4d2d08a6c6

Best regards,

Signature · 1 line
Niklas Schnelle
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

On a machine without PCI memory-I/O (MIO) support or when running with pci=nomio the s390 specific PCI MMIO write syscall checks if the MMIO cookie is above ZPCI_IOMAP_ADDR_BASE as a sanity check before even trying to perform the MMIO. If this check fails the return value was left unchanged and thus 0 from prior operations falsely indicating success. This could potentially confuse user-space into falsely believing the MMIO, on a mapping not valid for MMIO was successful.

Quoted 8 lines

Fix this by setting the return value to -EFAULT prior to the check following the same pattern as elsewhere in the same function.

Fixes a67a88b0b8de ("s390/pci: remove races against pte updates")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-b4-syscall_mmio_ret_fix_upstream-v1-1-6de516b33001@linux.ibm.com?part=1
maintainer Applied
#2 lore raw
In reply to Niklas Schnelle
Quoted 11 lines · Niklas Schnelle

On a machine without PCI memory-I/O (MIO) support or when running with pci=nomio the s390 specific PCI MMIO write syscall checks if the MMIO cookie is above ZPCI_IOMAP_ADDR_BASE as a sanity check before even trying to perform the MMIO. If this check fails the return value was left unchanged and thus 0 from prior operations falsely indicating success. This could potentially confuse user-space into falsely believing the MMIO, on a mapping not valid for MMIO was successful.

Fix this by setting the return value to -EFAULT prior to the check following the same pattern as elsewhere in the same function.

Quoted 8 lines
Fixes a67a88b0b8de ("s390/pci: remove races against pte updates")
---
 arch/s390/pci/pci_mmio.c | 1 +
 1 file changed, 1 insertion(+)

Applied, thank you!