Forwarded: Re: [syzbot] [pci?] BUG: unable to handle kernel paging request in pci_resource_io

syzbot <[email protected]>
Newsgroups gmane.linux.kernel
Message-ID <[email protected]>
For archival purposes, forwarding an incoming command email to
[email protected], [email protected].

***

Subject: Re: [syzbot] [pci?] BUG: unable to handle kernel paging request in pci_resource_io
Author: [email protected]

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git ba5cc80fd32665ed609037ff30ede8d194f24aab

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 5ec0b24..2aba909 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1175,6 +1175,16 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
 	if (port + count - 1 > pci_resource_end(pdev, bar))
 		return -EINVAL;

+	/*
+	 * Architectures that have no separate I/O address space emulate port
+	 * I/O with an MMIO window at PCI_IOBASE, so @port becomes an address
+	 * in a Device memory mapping.  Unaligned accesses to Device memory
+	 * fault there, and @port is fully controlled by the file offset, so
+	 * require the access to be naturally aligned.
+	 */
+	if (!IS_ALIGNED(port, count))
+		return -EINVAL;
+
 	switch (count) {
 	case 1:
 		if (write)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.