All of lore.kernel.org
 help / color / mirror / Atom feed
* PCI BAR sysfs node permissions
@ 2014-12-09 21:22 Dennis McLeod
  2014-12-09 21:48 ` Alex Williamson
  2014-12-14  3:39 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Dennis McLeod @ 2014-12-09 21:22 UTC (permalink / raw)
  To: linux-pci

need help figuring out how to make this happen. If my pci driver is
instructed to open a pci device, I want to change the mode of bar0's
sysfs node to o+rw so a user app can mmap it.

In other words, from the driver, perform this:
chmod 766 /sys/bus/pci/[slot path]/resource0
preferably without a lecture on why I shouldn't .. ;-)

If I chmod that sysfs node for bar0 as root, i can run a user process
(as regular user) that does an mmap of that and can do reads/writes to
the bar resource. I would like for my pci driver to do this
automatically when it is told to open a device.

Please help!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PCI BAR sysfs node permissions
  2014-12-09 21:22 PCI BAR sysfs node permissions Dennis McLeod
@ 2014-12-09 21:48 ` Alex Williamson
  2014-12-14  3:39 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2014-12-09 21:48 UTC (permalink / raw)
  To: Dennis McLeod; +Cc: linux-pci

On Tue, 2014-12-09 at 16:22 -0500, Dennis McLeod wrote:
> need help figuring out how to make this happen. If my pci driver is
> instructed to open a pci device, I want to change the mode of bar0's
> sysfs node to o+rw so a user app can mmap it.
> 
> In other words, from the driver, perform this:
> chmod 766 /sys/bus/pci/[slot path]/resource0
> preferably without a lecture on why I shouldn't .. ;-)
> 
> If I chmod that sysfs node for bar0 as root, i can run a user process
> (as regular user) that does an mmap of that and can do reads/writes to
> the bar resource. I would like for my pci driver to do this
> automatically when it is told to open a device.

This sounds like a future exploit.  Can the device to DMA?  Do you have
an IOMMU?  If yes & yes, have you heard of vfio-pci?  Thanks,

Alex


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PCI BAR sysfs node permissions
  2014-12-09 21:22 PCI BAR sysfs node permissions Dennis McLeod
  2014-12-09 21:48 ` Alex Williamson
@ 2014-12-14  3:39 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2014-12-14  3:39 UTC (permalink / raw)
  To: Dennis McLeod; +Cc: linux-pci

On Tue, Dec 09, 2014 at 04:22:35PM -0500, Dennis McLeod wrote:
> need help figuring out how to make this happen. If my pci driver is
> instructed to open a pci device, I want to change the mode of bar0's
> sysfs node to o+rw so a user app can mmap it.
> 
> In other words, from the driver, perform this:
> chmod 766 /sys/bus/pci/[slot path]/resource0
> preferably without a lecture on why I shouldn't .. ;-)

Sorry, you will get a lecture if you try to do something as foolish as
this from within the kernel.

If you "really" need this, do it from userspace, with a script you grant
root permissions to change the mode on the files.

> If I chmod that sysfs node for bar0 as root, i can run a user process
> (as regular user) that does an mmap of that and can do reads/writes to
> the bar resource. I would like for my pci driver to do this
> automatically when it is told to open a device.

Nope, that's a bad idea, and you know that as well.

sorry.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-14  5:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-09 21:22 PCI BAR sysfs node permissions Dennis McLeod
2014-12-09 21:48 ` Alex Williamson
2014-12-14  3:39 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.