Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can get a literal eqivalent to PEEK and POKE by mmap()ing /dev/mem. You can map the MMIO regions of a PCI device to write a userspace driver for it, for example. This is how I prodded the tl880 chip before I had a kernel module ready back when I was working on that driver.


That's pretty interesting. What are some of the limitations of an approach like that?


You don't get interrupt handlers, for one thing (though I think there are projects that do allow complete userspace drivers), and as binarycrusader mentioned, it's incredibly dangerous to give any process full access to the entire physical memory space. A single vulnerability in that process gives the attacker the ability to write to all of system memory. This can be mitigated somewhat by mmap()ing only the smallest possible region of interest, then dropping root privileges.


Yep, although most linux dists now have "/dev/mem protection" meaning that on stock distro kernels (Ubuntu, CentOS, etc), access to actual "physical memory" is disabled.

Ref: http://lwn.net/Articles/267427/

OK for driver development. If you need access to physical memory you have to compile a kernel with unrestricted /dev/mem.


> You don't get interrupt handlers, for one thing

Thanks.


It's a giant, gaping security hole that most operating system architects are desperately trying to get rid of -- at least, that's the way I view it.

Any software that uses it should be exposed to extra scrutiny and must judiciously leverage whatever privilege mechanisms an OS provides to mitigate damage.

There should be a better way to accomplish what xorg needs on *NIX systems.


Here's a recent, dramatic example about how that sort of memory use can go wrong:

http://www.androidpolice.com/2012/12/16/samsung-exynos-4-exp...


None, it works just fine for Xorg.

/s




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: