News for hackers. Stuff that matters.
Re:Peek and poke in the age of Linux by nitrogen on Sunday March 03, 2013 @02:22PM (#5314893)
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.
Re:Peek and poke in the age of Linux by justin66 on Sunday March 03, 2013 @02:27PM (#5314913)
That's pretty interesting. What are some of the limitations of an approach like that?
Re:Peek and poke in the age of Linux by nitrogen on Sunday March 03, 2013 @03:58PM (#5315210)
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.
Re:Peek and poke in the age of Linux by xyzzy123 on Sunday March 03, 2013 @10:20PM (#5316377)
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.

Re:Peek and poke in the age of Linux by justin66 on Sunday March 03, 2013 @06:11PM (#5315616)
> You don't get interrupt handlers, for one thing

Thanks.

Re:Peek and poke in the age of Linux by binarycrusader on Sunday March 03, 2013 @03:35PM (#5315144)
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.

Re:Peek and poke in the age of Linux by fpgeek on Sunday March 03, 2013 @10:59PM (#5316508)
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...

Re:Peek and poke in the age of Linux by tobiasu on Sunday March 03, 2013 @03:12PM (#5315073)
None, it works just fine for Xorg.

/s

Re:Peek and poke in the age of Linux by arocks on Sunday March 03, 2013 @01:51PM (#5314751)
For additional context: PEEK and POKE were commands used in the BASIC programming language for directly reading and writing to memory respectively.
Re:Peek and poke in the age of Linux by greenyoda on Sunday March 03, 2013 @03:19PM (#5315100)
There's even a Wikipedia article about them:

https://en.wikipedia.org/wiki/PEEK_and_POKE

Re:Peek and poke in the age of Linux by wslh on Sunday March 03, 2013 @06:49PM (#5315723)
And I even created a t-shirt from it!

http://swain.webframe.org/tshirts/ (look at the 3rd from the bottom)

Re:Peek and poke in the age of Linux by js2 on Sunday March 03, 2013 @07:14PM (#5315781)
The author doesn't say how upstart became deadlocked in the first place. Was this an upstart bug?
Re:Peek and poke in the age of Linux by viraptor on Sunday March 03, 2013 @08:00PM (#5315898)
Still unknown. Could be a bug, could be a race condition in one of the pre/post/start/stop blocks. I haven't seen it since and couldn't get a reliable reproducer. I really didn't want to make this about upstart itself so that people don't get to wrong conclusions.
Re:Peek and poke in the age of Linux by fforw on Sunday March 03, 2013 @07:16PM (#5315785)
Were there ever really common peek and pokes that would change programs?

Yes, "poke 53280,0" would directly write address 0xd020 to 0x00 which then e.g. would turn the border black on the C-64. But those were addresses in the mapped custom chips. More like setting a pixel on a modern GFX card by poke and less changing a program.

The later development of expansion cartridges to give you more lives in games or enable a cheat-mode there would a kind of peeking and poking, but hardware based etc.

Re:Peek and poke in the age of Linux by marrusl on Sunday March 03, 2013 @06:52PM (#5315731)
That's really cool. Another option with a stuck Upstart job is to rename the job file.

$ sudo mv /etc/init/myjob.conf /etc/init/myjob2.conf

$ sudo start myjob2