/proc/bus/pci allows you to mmap resource ranges too, so we should probably bechecking to make sure the mapping is somewhat valid. My main concern with this patch is that existing userland may be takingadvantage of the lax checking to map non-resource ranges, but we can alwaysback it out if that turns out to be the case. Anyway, comments & reviewappreciated as usual. Thanks,Jesse diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.cindex 110022d..cefaa5b 100644--- a/drivers/pci/pci-sysfs.c+++ b/drivers/pci/pci-sysfs.c@@ -569,7 +569,7 @@ void pci_remove_legacy_files(struct pci_bus *b) #ifdef HAVE_PCI_MMAP -static int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma)+int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma) { unsigned long nr, start, size; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.hindex 9de87e9..d3e65e2 100644--- a/drivers/pci/pci.h+++ b/drivers/pci/pci.h@@ -10,6 +10,10 @@ extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env); extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); extern void pci_cleanup_rom(struct pci_dev *dev);+#ifdef HAVE_PCI_MMAP+extern int pci_mmap_fits(struct pci_dev *pdev, int resno,+ struct vm_area_struct *vma);+#endif /** * Firmware PM callbacksdiff --git a/drivers/pci/proc.c b/drivers/pci/proc.cindex e1098c3..7fb086d 100644--- a/drivers/pci/proc.c+++ b/drivers/pci/proc.c@@ -252,11 +252,20 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) const struct proc_dir_entry *dp = PDE(inode); struct pci_dev *dev = dp->data; struct pci_filp_private *fpriv = file->private_data;- int ret;+ int i, ret; if (!capable(CAP_SYS_RAWIO)) return -EPERM; + /* Make sure the caller is mapping a real resource for this device */+ for (i = 0; i < PCI_ROM_RESOURCE; i++) {+ if (pci_mmap_fits(dev, i, vma))+ break;+ }++ if (i >= PCI_ROM_RESOURCE)+ return -ENODEV;+ ret = pci_mmap_page_range(dev, vma, fpriv->mmap_state, fpriv->write_combine); ÿôèº{.nÇ+?·?®??+%?Ëÿ±éݶ¥?wÿº{.nÇ+?·¥?{±þ?"þ)í?æèw*jg¬±¨¶????Ý¢jÿ¾«þG«?éÿ¢¸¢·¦j:+v?¨?wèjØm¶?ÿþø¯ù®w¥þ?àþf£¢·h??â?úÿ?Ù¥