Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time


This is a mildly terrifying local "chat" system that shirks networking protocols in favor of sending all messages directly through the kernel using its own kernel module. The idea is that user processes may open a file, and anything they read from this file will be messages from the chat room, and anything they write to this file will be broadcast to the entire chat room.

Interestingly enough, this turns out to be pretty darn close to a producer/consumer IPC mechanism, and since it has no real "chat features" (it's literally a byte pipe), this could conceivably even be used as a strange form of IPC.

Try It!

You'll need root on a Linux machine. I'm running 4.8.4, and it's entirely possible that this won't compile correctly on older versions.

# Build kchat_mod.ko, the kernel module
$ make

# Build the c client (optional)
# -> You can also use `cat` to read messages (not tail for some reason)
# -> You can use `dd of=filename` to write messages
$ gcc -o kchat_client kchat_client.c

# Load the kernel module
$ sudo insmod kchat_mod.ko

# Check for the device number from the module's output
$ dmesg | tail
# Use that number in the next command

# Create a "chat server" (i.e. a device file)
$ sudo mknod chat c 242 0

# Now run your clients (each in a separate window)
$ sudo kchat_client chat

# At this point all your terminals are "chatting" with each other!

What's Cool About It?

No really, I promise it's cool! If you don't believe me, check out the code for the client. It is really just reading, writing, and selecting from a couple files. If you looked at it, you wouldn't believe that it was a chat system!


My original inspiration came from the Linux Kernel Module Programming Guide, especially the chapter on character devices. Check that out here.

I was able to competently use data structures and locking primitives within the kernel thanks to Linux Kernel Development, Third Edition by Robert Love. If you're interested at all in kernel development, buy it from Amazon and stick it under your pillow at night.

I managed to hack together a good enough understanding of polling and wait queues to make the files work with both blocking and non-blocking I/O, thanks to the information from the Linux Device Drivers, 3rd Edition, which I accessed from here. Especially relevant are Sections 6.2 and 6.3!


As I normally do, this is released under the BSD 3 Clause license. Check LICENSE.txt for more info.


Kernel based chat system.







No releases published


No packages published