Require write access when mmapping BAR.

This actually makes the rights requirements for accessing PCI config
space and BARs using /dev/pci same.  Since unchanged /dev/pci mode
only allows write open for root, default configuration de-facto limits
the BAR read to root only.  In particular, state-changing reads of the
registers are limited to root.

Discussed with:	se
Suggested and reviewed by:	jhb (kernel part)
Sponsored by:	The FreeBSD Foundation
MFC after:	12 days
Differential revision:	https://reviews.freebsd.org/D16580
This commit is contained in:
Konstantin Belousov 2018-08-03 18:35:20 +00:00
parent 4b8eaf1441
commit 2e62782dac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=337269
2 changed files with 1 additions and 2 deletions

View File

@ -809,7 +809,6 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t
#endif
case PCIOCGETBAR:
case PCIOCLISTVPD:
case PCIOCBARMMAP:
break;
default:
return (EPERM);

View File

@ -1085,7 +1085,7 @@ dump_bar(const char *name, const char *reg, const char *bar_start,
pbm.pbm_flags = 0;
pbm.pbm_memattr = VM_MEMATTR_UNCACHEABLE; /* XXX */
fd = open(_PATH_DEVPCI, O_RDONLY, 0);
fd = open(_PATH_DEVPCI, O_RDWR, 0);
if (fd < 0)
err(1, "%s", _PATH_DEVPCI);