If you’ve ever looked in /dev you will have seen devices like cdrom and sda to denote storage mediums. You’ll have also seen tty and com devices.

/dev/greet: Invading Kernel Space

submited by
Style Pass
2021-06-26 11:30:07

If you’ve ever looked in /dev you will have seen devices like cdrom and sda to denote storage mediums. You’ll have also seen tty and com devices. These all act as a bridge between OS and hardware. You may also have seen pseudo-devices such as /dev/urandom and /dev/null which like to think and act like a real device, but in reality are just files playing pretend. We’re going to play pretend too by building a kernel module and pseudo-device which will allow us to get the approriate greeting for the time of day.

The code for this monstrosity can be found here, should you want to build along. If so, you’ll need to get the linux kernel source for your distro. I decided to experiment with this kernel module on Linux (Debian in particular) rather than my default OpenBSD, because the barrier to entry for loading random shit into the kernel is too high on OpenBSD. Make of that what you will. The code compiles with a few warnings that only real programmers care about.

Do you have a comment to make on this post? Start a discussion in my public inbox by emailing ~ols/public-inbox@lists.sr.ht. You can see the inbox here.

Leave a Comment