Linux Fu: Kernel Modules Have Privileges

I did something recently I haven’t done in a long time: I recompiled the Linux kernel. There was a time when this was a common occurrence. You might want a feature that the default kernel didn’t support, or you might have an odd piece of hardware. But these days, in almost all the cases where you need something like this, you’ll use loadable kernel modules (LKM) instead. These are modules that the kernel can load and unload at run time, which means you can add that new device or strange file system without having to rebuild or even restart the kernel.

Normally, when you write programs for Linux, they don’t have any special permissions. You typically can’t do direct port I/O, for example, or arbitrarily access memory. The kernel, however, including modules, has no such restriction. That can make debugging modules tricky because you can easily bring the system to its knees. If possible, you might think about developing on a virtual machine until you have what you want. That way, an errant module just brings down your virtual machine. Continue reading “Linux Fu: Kernel Modules Have Privileges”

Need A Linux Kernel Module? Scratch That

If you have been for (or against) Rust in the Linux kernel, get ready for a Linux kernel module written in… Scratch. That’s right. Scratch, the MIT-developed language with blocks popular for teaching kids to code. We didn’t mean “from scratch.” We meant IN Scratch. The bootstrap code and Makefile is out there on GitHub.

Of course, it is a simple module and the reason it is possible is because of the scratchnative system that lets you compile Scratch into C code. If you want to look at the decidedly simple code, you can open it in your browser.

Continue reading “Need A Linux Kernel Module? Scratch That”